<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.17"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>QuEST: QuEST_internal.h File Reference</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="style.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
                    <a class="navbar-brand"><b>QuEST</b> v3.2.0<br>The Quantum Exact Simulation Toolkit</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d522931ffa1371640980b621734a4381.html">Users</a></li><li class="navelem"><a class="el" href="dir_70834f0dcd10de01d2e35ab402a2238e.html">tysonjones</a></li><li class="navelem"><a class="el" href="dir_1957401ef452be7528010ba0f4832a45.html">Desktop</a></li><li class="navelem"><a class="el" href="dir_dee4414d5d72b49a9429e079789ffd08.html">GithubRepos</a></li><li class="navelem"><a class="el" href="dir_a89b43d59316bb5045aa22bb53a67d29.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_f1fe56bf5ef15ff22696c757278c6962.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_757750313c878cfe3b7d1ade55b4b819.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">QuEST_internal.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="QuEST_8h_source.html">QuEST.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="QuEST__precision_8h_source.html">QuEST_precision.h</a>&quot;</code><br />
</div>
<p><a href="QuEST__internal_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a8a8e789585651f90fcc587042d4cdfb8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a8a8e789585651f90fcc587042d4cdfb8">agnostic_applyTrotterCircuit</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structPauliHamil.html">PauliHamil</a> hamil, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> time, int order, int reps)</td></tr>
<tr class="separator:a8a8e789585651f90fcc587042d4cdfb8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0b84e6766bd682708e6211276ff0a5bb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a0b84e6766bd682708e6211276ff0a5bb">agnostic_createDiagonalOp</a> (int numQubits, <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="separator:a0b84e6766bd682708e6211276ff0a5bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af798bb01f922804016c4c5bc8d0a580f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#af798bb01f922804016c4c5bc8d0a580f">agnostic_destroyDiagonalOp</a> (<a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:af798bb01f922804016c4c5bc8d0a580f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab58d6d599c7a729255b1f8eeded663f3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab58d6d599c7a729255b1f8eeded663f3">agnostic_setDiagonalOpElems</a> (<a class="el" href="structDiagonalOp.html">DiagonalOp</a> op, long long int startInd, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *real, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *imag, long long int numElems)</td></tr>
<tr class="separator:ab58d6d599c7a729255b1f8eeded663f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1e8f917ab42d38d8c37ba6816b24f2f5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a1e8f917ab42d38d8c37ba6816b24f2f5">agnostic_syncDiagonalOp</a> (<a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a1e8f917ab42d38d8c37ba6816b24f2f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab17aea39cda8080d9f614bf737154f57"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab17aea39cda8080d9f614bf737154f57">conjugateMatrixN</a> (<a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="separator:ab17aea39cda8080d9f614bf737154f57"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aedd7ecccf2f09dd2f1c5d191950b51e6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aedd7ecccf2f09dd2f1c5d191950b51e6">densmatr_applyDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:aedd7ecccf2f09dd2f1c5d191950b51e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a70e3b0a2297c186d5c779af31459b4ca"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a70e3b0a2297c186d5c779af31459b4ca">densmatr_calcExpecDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a70e3b0a2297c186d5c779af31459b4ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa6c3f86010ad398f42b0577ea3bb5bcf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aa6c3f86010ad398f42b0577ea3bb5bcf">densmatr_calcFidelity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQureg.html">Qureg</a> pureState)</td></tr>
<tr class="separator:aa6c3f86010ad398f42b0577ea3bb5bcf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8c9da88f734b0862f4cce7d819e6d3b5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a8c9da88f734b0862f4cce7d819e6d3b5">densmatr_calcHilbertSchmidtDistance</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="separator:a8c9da88f734b0862f4cce7d819e6d3b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6ff3dc624b5fafe8edae4fe327c255a0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a6ff3dc624b5fafe8edae4fe327c255a0">densmatr_calcInnerProduct</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="separator:a6ff3dc624b5fafe8edae4fe327c255a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae37b3eff5d3affbc1edfe216cabc1c53"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ae37b3eff5d3affbc1edfe216cabc1c53">densmatr_calcProbOfOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome)</td></tr>
<tr class="separator:ae37b3eff5d3affbc1edfe216cabc1c53"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae45eefa65f4ecd37bab84fade7cf7f1f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ae45eefa65f4ecd37bab84fade7cf7f1f">densmatr_calcPurity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ae45eefa65f4ecd37bab84fade7cf7f1f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the trace of the density matrix squared.  <a href="QuEST__internal_8h.html#ae45eefa65f4ecd37bab84fade7cf7f1f">More...</a><br /></td></tr>
<tr class="separator:ae45eefa65f4ecd37bab84fade7cf7f1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6153547f245c05874161a105e9a2f02c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a6153547f245c05874161a105e9a2f02c">densmatr_calcTotalProb</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:a6153547f245c05874161a105e9a2f02c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5658f2ecbbd4ea425db5f7dc7fc4ba92"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> outcomeProb)</td></tr>
<tr class="memdesc:a5658f2ecbbd4ea425db5f7dc7fc4ba92"><td class="mdescLeft">&#160;</td><td class="mdescRight">Renorms (/prob) every | * outcome * &gt;&lt; * outcome * | state, setting all others to zero.  <a href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">More...</a><br /></td></tr>
<tr class="separator:a5658f2ecbbd4ea425db5f7dc7fc4ba92"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20a155f53efc45c16803d7539c2c199d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a20a155f53efc45c16803d7539c2c199d">densmatr_initClassicalState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int stateInd)</td></tr>
<tr class="separator:a20a155f53efc45c16803d7539c2c199d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2418bd9a6b9e6a0acf11faf5982d5d29"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2418bd9a6b9e6a0acf11faf5982d5d29">densmatr_initPlusState</a> (<a class="el" href="structQureg.html">Qureg</a> targetQureg)</td></tr>
<tr class="separator:a2418bd9a6b9e6a0acf11faf5982d5d29"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae5ad68d054875913d0f7ec654840a9ec"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ae5ad68d054875913d0f7ec654840a9ec">densmatr_initPureState</a> (<a class="el" href="structQureg.html">Qureg</a> targetQureg, <a class="el" href="structQureg.html">Qureg</a> copyQureg)</td></tr>
<tr class="separator:ae5ad68d054875913d0f7ec654840a9ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4ebc1f4dd48922bfb30ad1692310269"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ae4ebc1f4dd48922bfb30ad1692310269">densmatr_measureWithStats</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *outcomeProb)</td></tr>
<tr class="separator:ae4ebc1f4dd48922bfb30ad1692310269"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac501fe7b9d331be48359ce1546348f97"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ac501fe7b9d331be48359ce1546348f97">densmatr_mixDamping</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> damping)</td></tr>
<tr class="separator:ac501fe7b9d331be48359ce1546348f97"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8adaba9dbdad6f7ab41ae4b8db0abefe"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a8adaba9dbdad6f7ab41ae4b8db0abefe">densmatr_mixDensityMatrix</a> (<a class="el" href="structQureg.html">Qureg</a> combineQureg, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> otherProb, <a class="el" href="structQureg.html">Qureg</a> otherQureg)</td></tr>
<tr class="separator:a8adaba9dbdad6f7ab41ae4b8db0abefe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa31f0ef43a921c3ac73545d1d3670fa1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aa31f0ef43a921c3ac73545d1d3670fa1">densmatr_mixDephasing</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dephase)</td></tr>
<tr class="separator:aa31f0ef43a921c3ac73545d1d3670fa1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a398b60c4cb4fa2cf2ffc126de6c08da0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a398b60c4cb4fa2cf2ffc126de6c08da0">densmatr_mixDepolarising</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> depolLevel)</td></tr>
<tr class="separator:a398b60c4cb4fa2cf2ffc126de6c08da0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab987904f721746d1176aba7ac6b566fa"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab987904f721746d1176aba7ac6b566fa">densmatr_mixKrausMap</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int target, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> *ops, int numOps)</td></tr>
<tr class="separator:ab987904f721746d1176aba7ac6b566fa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99702f4667c429969d7e7b4ecd45c2f3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a99702f4667c429969d7e7b4ecd45c2f3">densmatr_mixMultiQubitKrausMap</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targets, int numTargets, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> *ops, int numOps)</td></tr>
<tr class="separator:a99702f4667c429969d7e7b4ecd45c2f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a74c14b1c46d838f5bf2bed1d5cf63271"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a74c14b1c46d838f5bf2bed1d5cf63271">densmatr_mixPauli</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> pX, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> pY, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> pZ)</td></tr>
<tr class="separator:a74c14b1c46d838f5bf2bed1d5cf63271"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a623e577b7230f3c8dc202be6185b4289"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dephase)</td></tr>
<tr class="separator:a623e577b7230f3c8dc202be6185b4289"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a43afa97e300b87bce7f3eb1213eb05f6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a43afa97e300b87bce7f3eb1213eb05f6">densmatr_mixTwoQubitDepolarising</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> depolLevel)</td></tr>
<tr class="separator:a43afa97e300b87bce7f3eb1213eb05f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab004038b5f906ea897621c88bf213129"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab004038b5f906ea897621c88bf213129">densmatr_mixTwoQubitKrausMap</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int target1, int target2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> *ops, int numOps)</td></tr>
<tr class="separator:ab004038b5f906ea897621c88bf213129"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac8ea84dd85eca525daeeb30b3c96b673"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ac8ea84dd85eca525daeeb30b3c96b673">ensureIndsIncrease</a> (int *ind1, int *ind2)</td></tr>
<tr class="separator:ac8ea84dd85eca525daeeb30b3c96b673"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a73300e3cdca56a7615980274905ba097"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a73300e3cdca56a7615980274905ba097">getComplexPairAndPhaseFromUnitary</a> (<a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u, <a class="el" href="structComplex.html">Complex</a> *alpha, <a class="el" href="structComplex.html">Complex</a> *beta, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *globalPhase)</td></tr>
<tr class="memdesc:a73300e3cdca56a7615980274905ba097"><td class="mdescLeft">&#160;</td><td class="mdescRight">maps U(r0c0, r0c1, r1c0, r1c1) to exp(i globalPhase) U(alpha, beta)  <a href="QuEST__internal_8h.html#a73300e3cdca56a7615980274905ba097">More...</a><br /></td></tr>
<tr class="separator:a73300e3cdca56a7615980274905ba097"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a71b3ae4402c1c5039d3086ca0e47a522"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a71b3ae4402c1c5039d3086ca0e47a522">getComplexPairFromRotation</a> (<a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, <a class="el" href="structVector.html">Vector</a> axis, <a class="el" href="structComplex.html">Complex</a> *alpha, <a class="el" href="structComplex.html">Complex</a> *beta)</td></tr>
<tr class="separator:a71b3ae4402c1c5039d3086ca0e47a522"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad34d98eeaa6a3cb45e92c696cfd2d1c8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ad34d98eeaa6a3cb45e92c696cfd2d1c8">getConjugateMatrix2</a> (<a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> src)</td></tr>
<tr class="separator:ad34d98eeaa6a3cb45e92c696cfd2d1c8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20d45e85dd49dd3bf6045990b590b24b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a20d45e85dd49dd3bf6045990b590b24b">getConjugateMatrix4</a> (<a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> src)</td></tr>
<tr class="separator:a20d45e85dd49dd3bf6045990b590b24b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af92fa737f4491324408b3d15543dced4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#af92fa737f4491324408b3d15543dced4">getConjugateScalar</a> (<a class="el" href="structComplex.html">Complex</a> scalar)</td></tr>
<tr class="separator:af92fa737f4491324408b3d15543dced4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6fa6f1bc617e9fef3cd87ecc3677a02b"><td class="memItemLeft" align="right" valign="top">long long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a6fa6f1bc617e9fef3cd87ecc3677a02b">getControlFlipMask</a> (int *controlQubits, int *controlState, int numControlQubits)</td></tr>
<tr class="separator:a6fa6f1bc617e9fef3cd87ecc3677a02b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0182eedcff44469771c971d8e2d73dc5"><td class="memItemLeft" align="right" valign="top">long long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a0182eedcff44469771c971d8e2d73dc5">getQubitBitMask</a> (int *controlQubits, int numControlQubits)</td></tr>
<tr class="separator:a0182eedcff44469771c971d8e2d73dc5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2b323b65cd6512720e6aa27c182fcea0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2b323b65cd6512720e6aa27c182fcea0">getQuESTDefaultSeedKey</a> (unsigned long int *key)</td></tr>
<tr class="separator:a2b323b65cd6512720e6aa27c182fcea0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3cf54148e2162b04aeb634badb90826c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a3cf54148e2162b04aeb634badb90826c">getVectorMagnitude</a> (<a class="el" href="structVector.html">Vector</a> vec)</td></tr>
<tr class="separator:a3cf54148e2162b04aeb634badb90826c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a404d177b894ce008289e44a599ad77d6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a404d177b894ce008289e44a599ad77d6">getZYZRotAnglesFromComplexPair</a> (<a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *rz2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *ry, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *rz1)</td></tr>
<tr class="memdesc:a404d177b894ce008289e44a599ad77d6"><td class="mdescLeft">&#160;</td><td class="mdescRight">maps U(alpha, beta) to Rz(rz2) Ry(ry) Rz(rz1)  <a href="QuEST__internal_8h.html#a404d177b894ce008289e44a599ad77d6">More...</a><br /></td></tr>
<tr class="separator:a404d177b894ce008289e44a599ad77d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab76254cfde16f0808476649507a1a2fc"><td class="memItemLeft" align="right" valign="top">unsigned long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab76254cfde16f0808476649507a1a2fc">hashString</a> (char *str)</td></tr>
<tr class="separator:ab76254cfde16f0808476649507a1a2fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9fd917537204e074119d4f283dea78e3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a9fd917537204e074119d4f283dea78e3">setConjugateMatrixN</a> (<a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> m)</td></tr>
<tr class="separator:a9fd917537204e074119d4f283dea78e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acf1c651a4359a370a2d9b3e1e1ebd430"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a> (int *indices, int numIndices, int shift)</td></tr>
<tr class="separator:acf1c651a4359a370a2d9b3e1e1ebd430"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27294e3065ebe42a65b3b9e0f85551dd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a27294e3065ebe42a65b3b9e0f85551dd">statevec_applyDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a27294e3065ebe42a65b3b9e0f85551dd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af71c2470694795a8d639be8ff9c34ed5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a> (<a class="el" href="structQureg.html">Qureg</a> inQureg, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *allCodes, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *termCoeffs, int numSumTerms, <a class="el" href="structQureg.html">Qureg</a> outQureg)</td></tr>
<tr class="separator:af71c2470694795a8d639be8ff9c34ed5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0fb948ddab4ca210e523aa3c52639df4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a0fb948ddab4ca210e523aa3c52639df4">statevec_calcExpecDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a0fb948ddab4ca210e523aa3c52639df4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aef380928d1b0003411d6159ca6594cd5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aef380928d1b0003411d6159ca6594cd5">statevec_calcExpecPauliProd</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targetQubits, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *pauliCodes, int numTargets, <a class="el" href="structQureg.html">Qureg</a> workspace)</td></tr>
<tr class="separator:aef380928d1b0003411d6159ca6594cd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae0cfea24091c8336146aa84c2253992e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ae0cfea24091c8336146aa84c2253992e">statevec_calcExpecPauliSum</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *allCodes, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *termCoeffs, int numSumTerms, <a class="el" href="structQureg.html">Qureg</a> workspace)</td></tr>
<tr class="separator:ae0cfea24091c8336146aa84c2253992e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeeec9fe1501e25930adf6c38763a158e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aeeec9fe1501e25930adf6c38763a158e">statevec_calcFidelity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQureg.html">Qureg</a> pureState)</td></tr>
<tr class="separator:aeeec9fe1501e25930adf6c38763a158e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7ebd3198a198f4cd20840f64fd8b84d0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a> (<a class="el" href="structQureg.html">Qureg</a> bra, <a class="el" href="structQureg.html">Qureg</a> ket)</td></tr>
<tr class="memdesc:a7ebd3198a198f4cd20840f64fd8b84d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Terrible code which unnecessarily individually computes and sums the real and imaginary components of the inner product, so as to not have to worry about keeping the sums separated during reduction.  <a href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">More...</a><br /></td></tr>
<tr class="separator:a7ebd3198a198f4cd20840f64fd8b84d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63cb88a5f4eb12fef087435b8db3f8eb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a63cb88a5f4eb12fef087435b8db3f8eb">statevec_calcProbOfOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome)</td></tr>
<tr class="separator:a63cb88a5f4eb12fef087435b8db3f8eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ad65ad1b5ea6f30b0c6b4ffda96e1a8e6">statevec_calcTotalProb</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa4b77089145184d990848cd66993aa8b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aa4b77089145184d990848cd66993aa8b">statevec_cloneQureg</a> (<a class="el" href="structQureg.html">Qureg</a> targetQureg, <a class="el" href="structQureg.html">Qureg</a> copyQureg)</td></tr>
<tr class="memdesc:aa4b77089145184d990848cd66993aa8b"><td class="mdescLeft">&#160;</td><td class="mdescRight">works for both statevectors and density matrices  <a href="QuEST__internal_8h.html#aa4b77089145184d990848cd66993aa8b">More...</a><br /></td></tr>
<tr class="separator:aa4b77089145184d990848cd66993aa8b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a008becc4a18f868340836e0ab9fd6df6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> outcomeProb)</td></tr>
<tr class="separator:a008becc4a18f868340836e0ab9fd6df6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aec63559e8b9ab0e17efe18d64d2ceca6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="separator:aec63559e8b9ab0e17efe18d64d2ceca6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae6cecbad32a03416138b321cdc1a2c33"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ae6cecbad32a03416138b321cdc1a2c33">statevec_compareStates</a> (<a class="el" href="structQureg.html">Qureg</a> mq1, <a class="el" href="structQureg.html">Qureg</a> mq2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> precision)</td></tr>
<tr class="separator:ae6cecbad32a03416138b321cdc1a2c33"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1275d604674224d87a173fb5bac78835"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a1275d604674224d87a173fb5bac78835">statevec_controlledCompactUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="separator:a1275d604674224d87a173fb5bac78835"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a06b8474aec51579ff680fb66439e7fc6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a06b8474aec51579ff680fb66439e7fc6">statevec_controlledMultiQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int ctrl, int *targets, int numTargets, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="separator:a06b8474aec51579ff680fb66439e7fc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abb2eab4af99adcc59be24f4c91c6f6ad"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#abb2eab4af99adcc59be24f4c91c6f6ad">statevec_controlledNot</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:abb2eab4af99adcc59be24f4c91c6f6ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4e19ef93d01d7acea32ca646d623aedd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a4e19ef93d01d7acea32ca646d623aedd">statevec_controlledPauliY</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:a4e19ef93d01d7acea32ca646d623aedd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a2fa262d3f0dba372797b9bd35d9fa5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a4a2fa262d3f0dba372797b9bd35d9fa5">statevec_controlledPauliYConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:a4a2fa262d3f0dba372797b9bd35d9fa5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf78491e35d165edfd57387f9fffecbd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aaf78491e35d165edfd57387f9fffecbd">statevec_controlledPhaseFlip</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int idQubit1, int idQubit2)</td></tr>
<tr class="separator:aaf78491e35d165edfd57387f9fffecbd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63df1ec14ff7cc81c3f392ac10fcc744"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a63df1ec14ff7cc81c3f392ac10fcc744">statevec_controlledPhaseShift</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int idQubit1, int idQubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:a63df1ec14ff7cc81c3f392ac10fcc744"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a336c3286d2434fc892ebe20e9fa22a24"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a336c3286d2434fc892ebe20e9fa22a24">statevec_controlledRotateAroundAxis</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, <a class="el" href="structVector.html">Vector</a> axis)</td></tr>
<tr class="separator:a336c3286d2434fc892ebe20e9fa22a24"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5ea2384a9b33c94eac891aacbfa5da6a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a5ea2384a9b33c94eac891aacbfa5da6a">statevec_controlledRotateAroundAxisConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, <a class="el" href="structVector.html">Vector</a> axis)</td></tr>
<tr class="separator:a5ea2384a9b33c94eac891aacbfa5da6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa32eed5bc38e85193e1aa23b74e8541b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aa32eed5bc38e85193e1aa23b74e8541b">statevec_controlledRotateX</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:aa32eed5bc38e85193e1aa23b74e8541b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ade67874c89179541f616b3685595d3ae"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ade67874c89179541f616b3685595d3ae">statevec_controlledRotateY</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:ade67874c89179541f616b3685595d3ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3e11a9b9fa5ee16d4738a97f4590ee61"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a3e11a9b9fa5ee16d4738a97f4590ee61">statevec_controlledRotateZ</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:a3e11a9b9fa5ee16d4738a97f4590ee61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad7ac4934371d72e24c6d1cea3d3da391"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ad7ac4934371d72e24c6d1cea3d3da391">statevec_controlledTwoQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit1, int targetQubit2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="separator:ad7ac4934371d72e24c6d1cea3d3da391"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:add9ca9956cdd81ed5d0b0f66168c04a3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#add9ca9956cdd81ed5d0b0f66168c04a3">statevec_controlledUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:add9ca9956cdd81ed5d0b0f66168c04a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a365bbb1b80cb00405c8bf1a4fa1ea8e5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a365bbb1b80cb00405c8bf1a4fa1ea8e5">statevec_createQureg</a> (<a class="el" href="structQureg.html">Qureg</a> *qureg, int numQubits, <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="separator:a365bbb1b80cb00405c8bf1a4fa1ea8e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a52ad9f9ad9b2fd6a76f6d433b3b217"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2a52ad9f9ad9b2fd6a76f6d433b3b217">statevec_destroyQureg</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="separator:a2a52ad9f9ad9b2fd6a76f6d433b3b217"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abd509244d57657e148e4084c5ab5d28f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="separator:abd509244d57657e148e4084c5ab5d28f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3afe58e49dce5536bc4c1b7caddf44a6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a3afe58e49dce5536bc4c1b7caddf44a6">statevec_getProbAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="separator:a3afe58e49dce5536bc4c1b7caddf44a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abc9a9ef4344c7faaaf28ac25c76649b9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="separator:abc9a9ef4344c7faaaf28ac25c76649b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af3fc7bd149c70f083b149050242cd55e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#af3fc7bd149c70f083b149050242cd55e">statevec_hadamard</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:af3fc7bd149c70f083b149050242cd55e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a758bad4237ff0bf3b4ff5be626a982ae"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a758bad4237ff0bf3b4ff5be626a982ae">statevec_initBlankState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:a758bad4237ff0bf3b4ff5be626a982ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a288dc4b46bdacd69cbf4a6fd070d26a7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a288dc4b46bdacd69cbf4a6fd070d26a7">statevec_initClassicalState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int stateInd)</td></tr>
<tr class="separator:a288dc4b46bdacd69cbf4a6fd070d26a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad9fd3017ea40cf63fd04b39e03494972"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">statevec_initDebugState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ad9fd3017ea40cf63fd04b39e03494972"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise the state vector of probability amplitudes to an (unphysical) state with each component of each probability amplitude a unique floating point value.  <a href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">More...</a><br /></td></tr>
<tr class="separator:ad9fd3017ea40cf63fd04b39e03494972"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a482fc361fd5f08075404c72e536316a0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a482fc361fd5f08075404c72e536316a0">statevec_initPlusState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:a482fc361fd5f08075404c72e536316a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a05756b45f10135bb2eeb07380f806c20"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a05756b45f10135bb2eeb07380f806c20">statevec_initStateFromSingleFile</a> (<a class="el" href="structQureg.html">Qureg</a> *qureg, char filename[200], <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="separator:a05756b45f10135bb2eeb07380f806c20"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a923906770cac0da9e3459bae58de9e64"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a923906770cac0da9e3459bae58de9e64">statevec_initStateOfSingleQubit</a> (<a class="el" href="structQureg.html">Qureg</a> *qureg, int qubitId, int outcome)</td></tr>
<tr class="memdesc:a923906770cac0da9e3459bae58de9e64"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise the state vector of probability amplitudes such that one qubit is set to 'outcome' and all other qubits are in an equal superposition of zero and one.  <a href="QuEST__internal_8h.html#a923906770cac0da9e3459bae58de9e64">More...</a><br /></td></tr>
<tr class="separator:a923906770cac0da9e3459bae58de9e64"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2ca0c6ba07ab2b4b437321bf17efc966"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2ca0c6ba07ab2b4b437321bf17efc966">statevec_initZeroState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:a2ca0c6ba07ab2b4b437321bf17efc966"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac2eb81c71d0e0fbec7be5b45b1db1448"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ac2eb81c71d0e0fbec7be5b45b1db1448">statevec_measureWithStats</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *outcomeProb)</td></tr>
<tr class="separator:ac2eb81c71d0e0fbec7be5b45b1db1448"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0acfe30083d0bc2a84da196378a36122"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlMask, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="memdesc:a0acfe30083d0bc2a84da196378a36122"><td class="mdescLeft">&#160;</td><td class="mdescRight">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct.  <a href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">More...</a><br /></td></tr>
<tr class="separator:a0acfe30083d0bc2a84da196378a36122"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac4ee5979d475e8c729294b8ef7e0270d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ac4ee5979d475e8c729294b8ef7e0270d">statevec_multiControlledPhaseFlip</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *controlQubits, int numControlQubits)</td></tr>
<tr class="separator:ac4ee5979d475e8c729294b8ef7e0270d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa662796ea6e0f471143c53becae8c12c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aa662796ea6e0f471143c53becae8c12c">statevec_multiControlledPhaseShift</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *controlQubits, int numControlQubits, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:aa662796ea6e0f471143c53becae8c12c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3eadcb581f2623e21e4967f791d0439c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a3eadcb581f2623e21e4967f791d0439c">statevec_multiControlledTwoQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlMask, int targetQubit1, int targetQubit2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="memdesc:a3eadcb581f2623e21e4967f791d0439c"><td class="mdescLeft">&#160;</td><td class="mdescRight">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct.  <a href="QuEST__internal_8h.html#a3eadcb581f2623e21e4967f791d0439c">More...</a><br /></td></tr>
<tr class="separator:a3eadcb581f2623e21e4967f791d0439c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a600bda10463e2078ce746ec28f2d39c9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a600bda10463e2078ce746ec28f2d39c9">statevec_multiControlledUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlQubitsMask, long long int ctrlFlipMask, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:a600bda10463e2078ce746ec28f2d39c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7a76950824f17e821415070a4bfdad5b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a7a76950824f17e821415070a4bfdad5b">statevec_multiQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targets, int numTargets, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="separator:a7a76950824f17e821415070a4bfdad5b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2153d8611247dd3a2ef483355265cc99"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2153d8611247dd3a2ef483355265cc99">statevec_multiRotatePauli</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targetQubits, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *targetPaulis, int numTargets, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, int applyConj)</td></tr>
<tr class="memdesc:a2153d8611247dd3a2ef483355265cc99"><td class="mdescLeft">&#160;</td><td class="mdescRight">applyConj=1 will apply conjugate operation, else applyConj=0  <a href="QuEST__internal_8h.html#a2153d8611247dd3a2ef483355265cc99">More...</a><br /></td></tr>
<tr class="separator:a2153d8611247dd3a2ef483355265cc99"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8d88b4ed94ab024e5e7b2f1f4f505b44"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a8d88b4ed94ab024e5e7b2f1f4f505b44">statevec_multiRotateZ</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int mask, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:a8d88b4ed94ab024e5e7b2f1f4f505b44"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1c82b5e914a8a39c5c7b782dbc16fa76"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a1c82b5e914a8a39c5c7b782dbc16fa76">statevec_pauliX</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a1c82b5e914a8a39c5c7b782dbc16fa76"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af1cca787f3b0e0c91ffb2495f9ad8d5a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#af1cca787f3b0e0c91ffb2495f9ad8d5a">statevec_pauliY</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:af1cca787f3b0e0c91ffb2495f9ad8d5a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81fbd2eccd0d0e5a3cece4df2f96cb92"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a81fbd2eccd0d0e5a3cece4df2f96cb92">statevec_pauliYConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a81fbd2eccd0d0e5a3cece4df2f96cb92"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab14df201e5c05527dc77cfeb6f583042"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab14df201e5c05527dc77cfeb6f583042">statevec_pauliZ</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:ab14df201e5c05527dc77cfeb6f583042"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5ef139196852f92fe8271c82964eadff"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a5ef139196852f92fe8271c82964eadff">statevec_phaseShift</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:a5ef139196852f92fe8271c82964eadff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a535cc3c9962d511078691e4d64b4e272"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplex.html">Complex</a> term)</td></tr>
<tr class="separator:a535cc3c9962d511078691e4d64b4e272"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1e57230c7995447039e62a84c0a36524"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">statevec_reportStateToScreen</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, int reportRank)</td></tr>
<tr class="memdesc:a1e57230c7995447039e62a84c0a36524"><td class="mdescLeft">&#160;</td><td class="mdescRight">Print the current state vector of probability amplitudes for a set of qubits to standard out.  <a href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">More...</a><br /></td></tr>
<tr class="separator:a1e57230c7995447039e62a84c0a36524"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf5fbea75826cde7d86fd7c31bcf3dec"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#adf5fbea75826cde7d86fd7c31bcf3dec">statevec_rotateAroundAxis</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int rotQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, <a class="el" href="structVector.html">Vector</a> axis)</td></tr>
<tr class="separator:adf5fbea75826cde7d86fd7c31bcf3dec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2cbfe9f416d4d8acb56213841f62cb53"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2cbfe9f416d4d8acb56213841f62cb53">statevec_rotateAroundAxisConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int rotQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, <a class="el" href="structVector.html">Vector</a> axis)</td></tr>
<tr class="separator:a2cbfe9f416d4d8acb56213841f62cb53"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab8687e6ea5cf35503c223051837f3b94"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab8687e6ea5cf35503c223051837f3b94">statevec_rotateX</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int rotQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:ab8687e6ea5cf35503c223051837f3b94"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1f0db2800d13b6c2b120e05129cd13cb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a1f0db2800d13b6c2b120e05129cd13cb">statevec_rotateY</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int rotQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:a1f0db2800d13b6c2b120e05129cd13cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2b2b8c69566a49cdf4a3fa2cb4f5e03c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2b2b8c69566a49cdf4a3fa2cb4f5e03c">statevec_rotateZ</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int rotQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle)</td></tr>
<tr class="separator:a2b2b8c69566a49cdf4a3fa2cb4f5e03c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa121d55f2ca09c06a96ddcd433c60b0f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#aa121d55f2ca09c06a96ddcd433c60b0f">statevec_setAmps</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int startInd, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *reals, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *imags, long long int numAmps)</td></tr>
<tr class="separator:aa121d55f2ca09c06a96ddcd433c60b0f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad64a23933361fafc1b6b1787759c2663"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ad64a23933361fafc1b6b1787759c2663">statevec_setWeightedQureg</a> (<a class="el" href="structComplex.html">Complex</a> fac1, <a class="el" href="structQureg.html">Qureg</a> qureg1, <a class="el" href="structComplex.html">Complex</a> fac2, <a class="el" href="structQureg.html">Qureg</a> qureg2, <a class="el" href="structComplex.html">Complex</a> facOut, <a class="el" href="structQureg.html">Qureg</a> out)</td></tr>
<tr class="separator:ad64a23933361fafc1b6b1787759c2663"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a559d175d31cec552fc09aec3e8a78d11"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a559d175d31cec552fc09aec3e8a78d11">statevec_sGate</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a559d175d31cec552fc09aec3e8a78d11"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a142b424d903dfaca7a7ac166076f543a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a142b424d903dfaca7a7ac166076f543a">statevec_sGateConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a142b424d903dfaca7a7ac166076f543a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6550462400942be61b171c8840b36aa1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a6550462400942be61b171c8840b36aa1">statevec_sqrtSwapGate</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qb1, int qb2)</td></tr>
<tr class="separator:a6550462400942be61b171c8840b36aa1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a33cde9b6518d55a544eff20301a5d844"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a33cde9b6518d55a544eff20301a5d844">statevec_sqrtSwapGateConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qb1, int qb2)</td></tr>
<tr class="separator:a33cde9b6518d55a544eff20301a5d844"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab7478fcaf6357ab202d72853b672e375"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qb1, int qb2)</td></tr>
<tr class="separator:ab7478fcaf6357ab202d72853b672e375"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d96b4601cc3a9e1221e11a366fe1699"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a2d96b4601cc3a9e1221e11a366fe1699">statevec_tGate</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a2d96b4601cc3a9e1221e11a366fe1699"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a086fffa88b1aeec1405aa2dc41eab8a3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a086fffa88b1aeec1405aa2dc41eab8a3">statevec_tGateConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a086fffa88b1aeec1405aa2dc41eab8a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a95abbe0cedf45b1ff2f070dba219fd7f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit1, int targetQubit2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="separator:a95abbe0cedf45b1ff2f070dba219fd7f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac3735bd959600e57b2ee3a105666cddf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__internal_8h.html#ac3735bd959600e57b2ee3a105666cddf">statevec_unitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:ac3735bd959600e57b2ee3a105666cddf"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>General functions used internally, supplied by QuEST_common or by hardware-specific backends. Note that some bespoke functions used only internally exist in <a class="el" href="QuEST__qasm_8h.html">QuEST_qasm.h</a> and <a class="el" href="QuEST__validation_8h.html">QuEST_validation.h</a></p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown (statevecs, original architecture) </dd>
<dd>
Tyson Jones (re-architecture, statevecs, density matrices) </dd></dl>

<p class="definition">Definition in file <a class="el" href="QuEST__internal_8h_source.html">QuEST_internal.h</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a8a8e789585651f90fcc587042d4cdfb8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8a8e789585651f90fcc587042d4cdfb8">&#9670;&nbsp;</a></span>agnostic_applyTrotterCircuit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void agnostic_applyTrotterCircuit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a>&#160;</td>
          <td class="paramname"><em>hamil</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>time</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>order</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>reps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00773">773</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00773"></a><span class="lineno">  773</span>&#160;                                                                                                  {</div>
<div class="line"><a name="l00774"></a><span class="lineno">  774</span>&#160;    </div>
<div class="line"><a name="l00775"></a><span class="lineno">  775</span>&#160;    <span class="keywordflow">if</span> (time == 0)</div>
<div class="line"><a name="l00776"></a><span class="lineno">  776</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00777"></a><span class="lineno">  777</span>&#160;    </div>
<div class="line"><a name="l00778"></a><span class="lineno">  778</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> r=0; r&lt;reps; r++)</div>
<div class="line"><a name="l00779"></a><span class="lineno">  779</span>&#160;        <a class="code" href="QuEST__common_8c.html#a4f419c557e4505da481879407a920541">applySymmetrizedTrotterCircuit</a>(qureg, hamil, time/reps, order);</div>
<div class="line"><a name="l00780"></a><span class="lineno">  780</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00753">applySymmetrizedTrotterCircuit()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00830">applyTrotterCircuit()</a>.</p>

</div>
</div>
<a id="a0b84e6766bd682708e6211276ff0a5bb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0b84e6766bd682708e6211276ff0a5bb">&#9670;&nbsp;</a></span>agnostic_createDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structDiagonalOp.html">DiagonalOp</a> agnostic_createDiagonalOp </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01335">1335</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01335"></a><span class="lineno"> 1335</span>&#160;                                                                  {</div>
<div class="line"><a name="l01336"></a><span class="lineno"> 1336</span>&#160; </div>
<div class="line"><a name="l01337"></a><span class="lineno"> 1337</span>&#160;    <span class="comment">// the 2^numQubits values will be evenly split between the env.numRanks nodes</span></div>
<div class="line"><a name="l01338"></a><span class="lineno"> 1338</span>&#160;    <a class="code" href="structDiagonalOp.html">DiagonalOp</a> op;</div>
<div class="line"><a name="l01339"></a><span class="lineno"> 1339</span>&#160;    op.<a class="code" href="structDiagonalOp.html#a5131eeb67aafb4c19ac98270c3266742">numQubits</a> = numQubits;</div>
<div class="line"><a name="l01340"></a><span class="lineno"> 1340</span>&#160;    op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a> = (1LL &lt;&lt; numQubits) / env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>;</div>
<div class="line"><a name="l01341"></a><span class="lineno"> 1341</span>&#160;    op.<a class="code" href="structDiagonalOp.html#aa91713a22c95a383bba55e56c4a4e37a">chunkId</a> = env.<a class="code" href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">rank</a>;</div>
<div class="line"><a name="l01342"></a><span class="lineno"> 1342</span>&#160;    op.<a class="code" href="structDiagonalOp.html#ada3bffa8e414f883e415dd74e46cd879">numChunks</a> = env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>;</div>
<div class="line"><a name="l01343"></a><span class="lineno"> 1343</span>&#160; </div>
<div class="line"><a name="l01344"></a><span class="lineno"> 1344</span>&#160;    <span class="comment">// allocate CPU memory (initialised to zero)</span></div>
<div class="line"><a name="l01345"></a><span class="lineno"> 1345</span>&#160;    op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a> = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) calloc(op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>));</div>
<div class="line"><a name="l01346"></a><span class="lineno"> 1346</span>&#160;    op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a> = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) calloc(op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>));</div>
<div class="line"><a name="l01347"></a><span class="lineno"> 1347</span>&#160; </div>
<div class="line"><a name="l01348"></a><span class="lineno"> 1348</span>&#160;    <span class="comment">// check cpu memory allocation was successful</span></div>
<div class="line"><a name="l01349"></a><span class="lineno"> 1349</span>&#160;    <span class="keywordflow">if</span> ( !op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a> || !op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a> ) {</div>
<div class="line"><a name="l01350"></a><span class="lineno"> 1350</span>&#160;        printf(<span class="stringliteral">&quot;Could not allocate memory!\n&quot;</span>);</div>
<div class="line"><a name="l01351"></a><span class="lineno"> 1351</span>&#160;        exit(EXIT_FAILURE);</div>
<div class="line"><a name="l01352"></a><span class="lineno"> 1352</span>&#160;    }</div>
<div class="line"><a name="l01353"></a><span class="lineno"> 1353</span>&#160; </div>
<div class="line"><a name="l01354"></a><span class="lineno"> 1354</span>&#160;    <span class="keywordflow">return</span> op;</div>
<div class="line"><a name="l01355"></a><span class="lineno"> 1355</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00187">DiagonalOp::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00193">DiagonalOp::deviceOperator</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00185">DiagonalOp::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00183">DiagonalOp::numElemsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00181">DiagonalOp::numQubits</a>, <a class="el" href="QuEST_8h_source.html#l00245">QuESTEnv::numRanks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00244">QuESTEnv::rank</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01267">createDiagonalOp()</a>.</p>

</div>
</div>
<a id="af798bb01f922804016c4c5bc8d0a580f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af798bb01f922804016c4c5bc8d0a580f">&#9670;&nbsp;</a></span>agnostic_destroyDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void agnostic_destroyDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01357">1357</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01357"></a><span class="lineno"> 1357</span>&#160;                                               {</div>
<div class="line"><a name="l01358"></a><span class="lineno"> 1358</span>&#160;    free(op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>);</div>
<div class="line"><a name="l01359"></a><span class="lineno"> 1359</span>&#160;    free(op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>);</div>
<div class="line"><a name="l01360"></a><span class="lineno"> 1360</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00193">DiagonalOp::deviceOperator</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01273">destroyDiagonalOp()</a>.</p>

</div>
</div>
<a id="ab58d6d599c7a729255b1f8eeded663f3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab58d6d599c7a729255b1f8eeded663f3">&#9670;&nbsp;</a></span>agnostic_setDiagonalOpElems()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void agnostic_setDiagonalOpElems </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>startInd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>real</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>imag</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>numElems</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03842">3842</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03842"></a><span class="lineno"> 3842</span>&#160;                                                                                                                          {</div>
<div class="line"><a name="l03843"></a><span class="lineno"> 3843</span>&#160;    </div>
<div class="line"><a name="l03844"></a><span class="lineno"> 3844</span>&#160;    <span class="comment">// local start/end indices of the given amplitudes, assuming they fit in this chunk</span></div>
<div class="line"><a name="l03845"></a><span class="lineno"> 3845</span>&#160;    <span class="comment">// these may be negative or above qureg.numAmpsPerChunk</span></div>
<div class="line"><a name="l03846"></a><span class="lineno"> 3846</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localStartInd = startInd - op.<a class="code" href="structDiagonalOp.html#aa91713a22c95a383bba55e56c4a4e37a">chunkId</a>*op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>;</div>
<div class="line"><a name="l03847"></a><span class="lineno"> 3847</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localEndInd = localStartInd + numElems; <span class="comment">// exclusive</span></div>
<div class="line"><a name="l03848"></a><span class="lineno"> 3848</span>&#160;    </div>
<div class="line"><a name="l03849"></a><span class="lineno"> 3849</span>&#160;    <span class="comment">// add this to a local index to get corresponding elem in reals &amp; imags</span></div>
<div class="line"><a name="l03850"></a><span class="lineno"> 3850</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> offset = op.<a class="code" href="structDiagonalOp.html#aa91713a22c95a383bba55e56c4a4e37a">chunkId</a>*op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a> - startInd;</div>
<div class="line"><a name="l03851"></a><span class="lineno"> 3851</span>&#160;    </div>
<div class="line"><a name="l03852"></a><span class="lineno"> 3852</span>&#160;    <span class="comment">// restrict these indices to fit into this chunk</span></div>
<div class="line"><a name="l03853"></a><span class="lineno"> 3853</span>&#160;    <span class="keywordflow">if</span> (localStartInd &lt; 0)</div>
<div class="line"><a name="l03854"></a><span class="lineno"> 3854</span>&#160;        localStartInd = 0;</div>
<div class="line"><a name="l03855"></a><span class="lineno"> 3855</span>&#160;    <span class="keywordflow">if</span> (localEndInd &gt; op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>)</div>
<div class="line"><a name="l03856"></a><span class="lineno"> 3856</span>&#160;        localEndInd = op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>;</div>
<div class="line"><a name="l03857"></a><span class="lineno"> 3857</span>&#160;    <span class="comment">// they may now be out of order = no iterations</span></div>
<div class="line"><a name="l03858"></a><span class="lineno"> 3858</span>&#160;    </div>
<div class="line"><a name="l03859"></a><span class="lineno"> 3859</span>&#160;    <span class="comment">// unpacking OpenMP vars</span></div>
<div class="line"><a name="l03860"></a><span class="lineno"> 3860</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03861"></a><span class="lineno"> 3861</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecRe = op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>;</div>
<div class="line"><a name="l03862"></a><span class="lineno"> 3862</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecIm = op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>;</div>
<div class="line"><a name="l03863"></a><span class="lineno"> 3863</span>&#160;    </div>
<div class="line"><a name="l03864"></a><span class="lineno"> 3864</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03865"></a><span class="lineno"> 3865</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03866"></a><span class="lineno"> 3866</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l03867"></a><span class="lineno"> 3867</span>&#160;<span class="preprocessor">    shared   (localStartInd,localEndInd, vecRe,vecIm, real,imag, offset) \</span></div>
<div class="line"><a name="l03868"></a><span class="lineno"> 3868</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l03869"></a><span class="lineno"> 3869</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03870"></a><span class="lineno"> 3870</span>&#160;    {</div>
<div class="line"><a name="l03871"></a><span class="lineno"> 3871</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03872"></a><span class="lineno"> 3872</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03873"></a><span class="lineno"> 3873</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03874"></a><span class="lineno"> 3874</span>&#160;        <span class="comment">// iterate these local inds - this might involve no iterations</span></div>
<div class="line"><a name="l03875"></a><span class="lineno"> 3875</span>&#160;        <span class="keywordflow">for</span> (index=localStartInd; index &lt; localEndInd; index++) {</div>
<div class="line"><a name="l03876"></a><span class="lineno"> 3876</span>&#160;            vecRe[index] = real[index + offset];</div>
<div class="line"><a name="l03877"></a><span class="lineno"> 3877</span>&#160;            vecIm[index] = imag[index + offset];</div>
<div class="line"><a name="l03878"></a><span class="lineno"> 3878</span>&#160;        }</div>
<div class="line"><a name="l03879"></a><span class="lineno"> 3879</span>&#160;    }</div>
<div class="line"><a name="l03880"></a><span class="lineno"> 3880</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00187">DiagonalOp::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00193">DiagonalOp::deviceOperator</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00183">DiagonalOp::numElemsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01286">initDiagonalOp()</a>, and <a class="el" href="QuEST_8c_source.html#l01292">setDiagonalOpElems()</a>.</p>

</div>
</div>
<a id="a1e8f917ab42d38d8c37ba6816b24f2f5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1e8f917ab42d38d8c37ba6816b24f2f5">&#9670;&nbsp;</a></span>agnostic_syncDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void agnostic_syncDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01362">1362</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01362"></a><span class="lineno"> 1362</span>&#160;                                            {</div>
<div class="line"><a name="l01363"></a><span class="lineno"> 1363</span>&#160;    <span class="comment">// nothing to do on CPU</span></div>
<div class="line"><a name="l01364"></a><span class="lineno"> 1364</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00193">DiagonalOp::deviceOperator</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00181">DiagonalOp::numQubits</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01280">syncDiagonalOp()</a>.</p>

</div>
</div>
<a id="ab17aea39cda8080d9f614bf737154f57"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab17aea39cda8080d9f614bf737154f57">&#9670;&nbsp;</a></span>conjugateMatrixN()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void conjugateMatrixN </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="aedd7ecccf2f09dd2f1c5d191950b51e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aedd7ecccf2f09dd2f1c5d191950b51e6">&#9670;&nbsp;</a></span>densmatr_applyDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_applyDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01517">1517</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01517"></a><span class="lineno"> 1517</span>&#160;                                                          {</div>
<div class="line"><a name="l01518"></a><span class="lineno"> 1518</span>&#160;    </div>
<div class="line"><a name="l01519"></a><span class="lineno"> 1519</span>&#160;    <a class="code" href="QuEST__cpu__distributed_8c.html#aefba328e047e6ef4fd1ae4b56901aaa7">copyDiagOpIntoMatrixPairState</a>(qureg, op);</div>
<div class="line"><a name="l01520"></a><span class="lineno"> 1520</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#afa58cf7cb98a25ab33621120c5c330d0">densmatr_applyDiagonalOpLocal</a>(qureg, op);</div>
<div class="line"><a name="l01521"></a><span class="lineno"> 1521</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01482">copyDiagOpIntoMatrixPairState()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03696">densmatr_applyDiagonalOpLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00887">applyDiagonalOp()</a>.</p>

</div>
</div>
<a id="a70e3b0a2297c186d5c779af31459b4ca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a70e3b0a2297c186d5c779af31459b4ca">&#9670;&nbsp;</a></span>densmatr_calcExpecDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> densmatr_calcExpecDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01541">1541</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01541"></a><span class="lineno"> 1541</span>&#160;                                                                 {</div>
<div class="line"><a name="l01542"></a><span class="lineno"> 1542</span>&#160;    </div>
<div class="line"><a name="l01543"></a><span class="lineno"> 1543</span>&#160;    <a class="code" href="structComplex.html">Complex</a> localVal = <a class="code" href="QuEST__cpu_8c.html#aeb4453a2e609e5359d2995bccf6663ca">densmatr_calcExpecDiagonalOpLocal</a>(qureg, op);</div>
<div class="line"><a name="l01544"></a><span class="lineno"> 1544</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> == 1)</div>
<div class="line"><a name="l01545"></a><span class="lineno"> 1545</span>&#160;        <span class="keywordflow">return</span> localVal;</div>
<div class="line"><a name="l01546"></a><span class="lineno"> 1546</span>&#160;    </div>
<div class="line"><a name="l01547"></a><span class="lineno"> 1547</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localRe = localVal.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l01548"></a><span class="lineno"> 1548</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localIm = localVal.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l01549"></a><span class="lineno"> 1549</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalRe, globalIm;</div>
<div class="line"><a name="l01550"></a><span class="lineno"> 1550</span>&#160;    </div>
<div class="line"><a name="l01551"></a><span class="lineno"> 1551</span>&#160;    MPI_Allreduce(&amp;localRe, &amp;globalRe, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01552"></a><span class="lineno"> 1552</span>&#160;    MPI_Allreduce(&amp;localIm, &amp;globalIm, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01553"></a><span class="lineno"> 1553</span>&#160;    </div>
<div class="line"><a name="l01554"></a><span class="lineno"> 1554</span>&#160;    <a class="code" href="structComplex.html">Complex</a> globalVal;</div>
<div class="line"><a name="l01555"></a><span class="lineno"> 1555</span>&#160;    globalVal.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = globalRe;</div>
<div class="line"><a name="l01556"></a><span class="lineno"> 1556</span>&#160;    globalVal.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = globalIm;</div>
<div class="line"><a name="l01557"></a><span class="lineno"> 1557</span>&#160;    <span class="keywordflow">return</span> globalVal;</div>
<div class="line"><a name="l01558"></a><span class="lineno"> 1558</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03781">densmatr_calcExpecDiagonalOpLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00193">DiagonalOp::deviceOperator</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00181">DiagonalOp::numQubits</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00979">calcExpecDiagonalOp()</a>.</p>

</div>
</div>
<a id="aa6c3f86010ad398f42b0577ea3bb5bcf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa6c3f86010ad398f42b0577ea3bb5bcf">&#9670;&nbsp;</a></span>densmatr_calcFidelity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcFidelity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>pureState</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00415">415</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;                                                          {</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;    </div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;    <span class="comment">// set qureg&#39;s pairState is to be the full pureState (on every node)</span></div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;    <a class="code" href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a>(qureg, pureState);</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160; </div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;    <span class="comment">// collect calcFidelityLocal by every machine</span></div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localSum = <a class="code" href="QuEST__cpu_8c.html#a7772f97cb4d92a9825bf3b7c82c3230c">densmatr_calcFidelityLocal</a>(qureg, pureState);</div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;    </div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;    <span class="comment">// sum each localSum</span></div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSum;</div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;    MPI_Allreduce(&amp;localSum, &amp;globalSum, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;    </div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;    <span class="keywordflow">return</span> globalSum;</div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00371">copyVecIntoMatrixPairState()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00990">densmatr_calcFidelityLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00942">calcFidelity()</a>.</p>

</div>
</div>
<a id="a8c9da88f734b0862f4cce7d819e6d3b5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8c9da88f734b0862f4cce7d819e6d3b5">&#9670;&nbsp;</a></span>densmatr_calcHilbertSchmidtDistance()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcHilbertSchmidtDistance </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00430">430</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;                                                            {</div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;    </div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localSum = <a class="code" href="QuEST__cpu_8c.html#a939897137596bb73ad7a028d0beaaa10">densmatr_calcHilbertSchmidtDistanceSquaredLocal</a>(a, b);</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;    </div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSum;</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;    MPI_Allreduce(&amp;localSum, &amp;globalSum, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;    </div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dist = sqrt(globalSum);</div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;    <span class="keywordflow">return</span> dist;</div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00923">densmatr_calcHilbertSchmidtDistanceSquaredLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00988">calcHilbertSchmidtDistance()</a>.</p>

</div>
</div>
<a id="a6ff3dc624b5fafe8edae4fe327c255a0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6ff3dc624b5fafe8edae4fe327c255a0">&#9670;&nbsp;</a></span>densmatr_calcInnerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcInnerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00441">441</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;                                                  {</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;    </div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localSum = <a class="code" href="QuEST__cpu_8c.html#a08392b1b27d10e3b8a8648a5afeaa629">densmatr_calcInnerProductLocal</a>(a, b);</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;    </div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSum;</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;    MPI_Allreduce(&amp;localSum, &amp;globalSum, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    </div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dist = globalSum;</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;    <span class="keywordflow">return</span> dist;</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00958">densmatr_calcInnerProductLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00918">calcDensityInnerProduct()</a>.</p>

</div>
</div>
<a id="ae37b3eff5d3affbc1edfe216cabc1c53"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae37b3eff5d3affbc1edfe216cabc1c53">&#9670;&nbsp;</a></span>densmatr_calcProbOfOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcProbOfOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01276">1276</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01276"></a><span class="lineno"> 1276</span>&#160;                                                                             {</div>
<div class="line"><a name="l01277"></a><span class="lineno"> 1277</span>&#160;        </div>
<div class="line"><a name="l01278"></a><span class="lineno"> 1278</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> zeroProb = <a class="code" href="QuEST__cpu_8c.html#a8bea931504c90d9bd97e74645667804e">densmatr_findProbabilityOfZeroLocal</a>(qureg, measureQubit);</div>
<div class="line"><a name="l01279"></a><span class="lineno"> 1279</span>&#160;        </div>
<div class="line"><a name="l01280"></a><span class="lineno"> 1280</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> outcomeProb;</div>
<div class="line"><a name="l01281"></a><span class="lineno"> 1281</span>&#160;        MPI_Allreduce(&amp;zeroProb, &amp;outcomeProb, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01282"></a><span class="lineno"> 1282</span>&#160;        <span class="keywordflow">if</span> (outcome == 1)</div>
<div class="line"><a name="l01283"></a><span class="lineno"> 1283</span>&#160;                outcomeProb = 1.0 - outcomeProb;</div>
<div class="line"><a name="l01284"></a><span class="lineno"> 1284</span>&#160;        </div>
<div class="line"><a name="l01285"></a><span class="lineno"> 1285</span>&#160;        <span class="keywordflow">return</span> outcomeProb;</div>
<div class="line"><a name="l01286"></a><span class="lineno"> 1286</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01919">densmatr_findProbabilityOfZero()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03151">densmatr_findProbabilityOfZeroLocal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00926">calcProbOfOutcome()</a>, <a class="el" href="QuEST_8c_source.html#l00726">collapseToOutcome()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00369">densmatr_measureWithStats()</a>.</p>

</div>
</div>
<a id="ae45eefa65f4ecd37bab84fade7cf7f1f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae45eefa65f4ecd37bab84fade7cf7f1f">&#9670;&nbsp;</a></span>densmatr_calcPurity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcPurity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the trace of the density matrix squared. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01288">1288</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01288"></a><span class="lineno"> 1288</span>&#160;                                       {</div>
<div class="line"><a name="l01289"></a><span class="lineno"> 1289</span>&#160;    </div>
<div class="line"><a name="l01290"></a><span class="lineno"> 1290</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localPurity = <a class="code" href="QuEST__cpu_8c.html#af910c7cf2b85bdc2c399cfe8dbfb8b9c">densmatr_calcPurityLocal</a>(qureg);</div>
<div class="line"><a name="l01291"></a><span class="lineno"> 1291</span>&#160;        </div>
<div class="line"><a name="l01292"></a><span class="lineno"> 1292</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalPurity;</div>
<div class="line"><a name="l01293"></a><span class="lineno"> 1293</span>&#160;    MPI_Allreduce(&amp;localPurity, &amp;globalPurity, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01294"></a><span class="lineno"> 1294</span>&#160;    </div>
<div class="line"><a name="l01295"></a><span class="lineno"> 1295</span>&#160;    <span class="keywordflow">return</span> globalPurity;</div>
<div class="line"><a name="l01296"></a><span class="lineno"> 1296</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00861">densmatr_calcPurityLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00936">calcPurity()</a>.</p>

</div>
</div>
<a id="a6153547f245c05874161a105e9a2f02c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6153547f245c05874161a105e9a2f02c">&#9670;&nbsp;</a></span>densmatr_calcTotalProb()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcTotalProb </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00053">53</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;                                          {</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        </div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        <span class="comment">// computes the trace by summing every element (&quot;diag&quot;) with global index (2^n + 1)i for i in [0, 2^n-1]</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        </div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <span class="comment">// computes first local index containing a diagonal element</span></div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> diagSpacing = 1LL + (1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numPrevDiags = (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>&gt;0)? 1+(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>)/diagSpacing : 0;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> globalIndNextDiag = diagSpacing * numPrevDiags;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localIndNextDiag = globalIndNextDiag % qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        </div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> rankTotal = 0;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> y, t, c;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        c = 0;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="comment">// iterates every local diagonal</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <span class="keywordflow">for</span> (index=localIndNextDiag; index &lt; qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; index += diagSpacing) {</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                </div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;                <span class="comment">// Kahan summation - brackets are important</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;                y = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index] - c;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;                t = rankTotal + y;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                c = ( t - rankTotal ) - y;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;                rankTotal = t;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        }</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        </div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <span class="comment">// combine each node&#39;s sum of diagonals</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalTotal;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> &gt; 1)</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                MPI_Allreduce(&amp;rankTotal, &amp;globalTotal, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        <span class="keywordflow">else</span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                globalTotal = rankTotal;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        </div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        <span class="keywordflow">return</span> globalTotal;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00461">copyStateFromGPU()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00903">calcTotalProb()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00465">statevec_calcExpecPauliProd()</a>.</p>

</div>
</div>
<a id="a5658f2ecbbd4ea425db5f7dc7fc4ba92"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5658f2ecbbd4ea425db5f7dc7fc4ba92">&#9670;&nbsp;</a></span>densmatr_collapseToKnownProbOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_collapseToKnownProbOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>outcomeProb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Renorms (/prob) every | * outcome * &gt;&lt; * outcome * | state, setting all others to zero. </p>
<p>Renorms (/prob) every | * outcome * &gt;&lt; * outcome * | state, setting all others to zero. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00785">785</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00785"></a><span class="lineno">  785</span>&#160;                                                                                                           {</div>
<div class="line"><a name="l00786"></a><span class="lineno">  786</span>&#160; </div>
<div class="line"><a name="l00787"></a><span class="lineno">  787</span>&#160;        <span class="comment">// only (global) indices (as bit sequence): &#39;* outcome *(n+q) outcome *q are spared</span></div>
<div class="line"><a name="l00788"></a><span class="lineno">  788</span>&#160;    <span class="comment">// where n = measureQubit, q = qureg.numQubitsRepresented.</span></div>
<div class="line"><a name="l00789"></a><span class="lineno">  789</span>&#160;    <span class="comment">// We can thus step in blocks of 2^q+n, killing every second, and inside the others,</span></div>
<div class="line"><a name="l00790"></a><span class="lineno">  790</span>&#160;    <span class="comment">//  stepping in sub-blocks of 2^q, killing every second.</span></div>
<div class="line"><a name="l00791"></a><span class="lineno">  791</span>&#160;    <span class="comment">// When outcome=1, we offset the start of these blocks by their size.</span></div>
<div class="line"><a name="l00792"></a><span class="lineno">  792</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> innerBlockSize = (1LL &lt;&lt; measureQubit);</div>
<div class="line"><a name="l00793"></a><span class="lineno">  793</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> outerBlockSize = (1LL &lt;&lt; (measureQubit + qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>));</div>
<div class="line"><a name="l00794"></a><span class="lineno">  794</span>&#160;    </div>
<div class="line"><a name="l00795"></a><span class="lineno">  795</span>&#160;    <span class="comment">// Because there are 2^a number of nodes(/chunks), each node will contain 2^b number of blocks,</span></div>
<div class="line"><a name="l00796"></a><span class="lineno">  796</span>&#160;    <span class="comment">// or each block will span 2^c number of nodes. Similarly for the innerblocks.</span></div>
<div class="line"><a name="l00797"></a><span class="lineno">  797</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> locNumAmps = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00798"></a><span class="lineno">  798</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> globalStartInd = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * locNumAmps;</div>
<div class="line"><a name="l00799"></a><span class="lineno">  799</span>&#160;    <span class="keywordtype">int</span> innerBit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(measureQubit, globalStartInd);</div>
<div class="line"><a name="l00800"></a><span class="lineno">  800</span>&#160;    <span class="keywordtype">int</span> outerBit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(measureQubit + qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, globalStartInd);</div>
<div class="line"><a name="l00801"></a><span class="lineno">  801</span>&#160;    </div>
<div class="line"><a name="l00802"></a><span class="lineno">  802</span>&#160;    <span class="comment">// If this chunk&#39;s amps are entirely inside an outer block</span></div>
<div class="line"><a name="l00803"></a><span class="lineno">  803</span>&#160;    <span class="keywordflow">if</span> (locNumAmps &lt;= outerBlockSize) {</div>
<div class="line"><a name="l00804"></a><span class="lineno">  804</span>&#160;        </div>
<div class="line"><a name="l00805"></a><span class="lineno">  805</span>&#160;        <span class="comment">// if this is an undesired outer block, kill all elems</span></div>
<div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;        <span class="keywordflow">if</span> (outerBit != outcome)</div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160;            <span class="keywordflow">return</span> <a class="code" href="QuEST__cpu_8c.html#ac5168399122f7f53977dcc9ceda4f458">zeroSomeAmps</a>(qureg, 0, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>);</div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;        </div>
<div class="line"><a name="l00809"></a><span class="lineno">  809</span>&#160;        <span class="comment">// othwerwise, if this is a desired outer block, and also entirely an inner block</span></div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;        <span class="keywordflow">if</span> (locNumAmps &lt;= innerBlockSize) {</div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;            </div>
<div class="line"><a name="l00812"></a><span class="lineno">  812</span>&#160;            <span class="comment">// and that inner block is undesired, kill all elems</span></div>
<div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;            <span class="keywordflow">if</span> (innerBit != outcome)</div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;                <span class="keywordflow">return</span> <a class="code" href="QuEST__cpu_8c.html#ac5168399122f7f53977dcc9ceda4f458">zeroSomeAmps</a>(qureg, 0, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>);</div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;            <span class="comment">// otherwise normalise all elems</span></div>
<div class="line"><a name="l00816"></a><span class="lineno">  816</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00817"></a><span class="lineno">  817</span>&#160;                <span class="keywordflow">return</span> <a class="code" href="QuEST__cpu_8c.html#a031a99b7e97779f3dc782feffe86e779">normaliseSomeAmps</a>(qureg, totalStateProb, 0, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>);</div>
<div class="line"><a name="l00818"></a><span class="lineno">  818</span>&#160;        }</div>
<div class="line"><a name="l00819"></a><span class="lineno">  819</span>&#160;                </div>
<div class="line"><a name="l00820"></a><span class="lineno">  820</span>&#160;        <span class="comment">// otherwise this is a desired outer block which contains 2^a inner blocks; kill/renorm every second inner block</span></div>
<div class="line"><a name="l00821"></a><span class="lineno">  821</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__cpu_8c.html#a0abdff5f6065f9d57065345e6d90fc94">alternateNormZeroingSomeAmpBlocks</a>(</div>
<div class="line"><a name="l00822"></a><span class="lineno">  822</span>&#160;            qureg, totalStateProb, innerBit==outcome, 0, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, innerBlockSize);</div>
<div class="line"><a name="l00823"></a><span class="lineno">  823</span>&#160;    }</div>
<div class="line"><a name="l00824"></a><span class="lineno">  824</span>&#160;    </div>
<div class="line"><a name="l00825"></a><span class="lineno">  825</span>&#160;    <span class="comment">// Otherwise, this chunk&#39;s amps contain multiple outer blocks (and hence multiple inner blocks)</span></div>
<div class="line"><a name="l00826"></a><span class="lineno">  826</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numOuterDoubleBlocks = locNumAmps / (2*outerBlockSize);</div>
<div class="line"><a name="l00827"></a><span class="lineno">  827</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> firstBlockInd;</div>
<div class="line"><a name="l00828"></a><span class="lineno">  828</span>&#160;    </div>
<div class="line"><a name="l00829"></a><span class="lineno">  829</span>&#160;    <span class="comment">// alternate norming* and zeroing the outer blocks (with order based on the desired outcome)</span></div>
<div class="line"><a name="l00830"></a><span class="lineno">  830</span>&#160;    <span class="comment">// These loops aren&#39;t parallelised, since they could have 1 or 2 iterations and will prevent</span></div>
<div class="line"><a name="l00831"></a><span class="lineno">  831</span>&#160;    <span class="comment">// inner parallelisation</span></div>
<div class="line"><a name="l00832"></a><span class="lineno">  832</span>&#160;    <span class="keywordflow">if</span> (outerBit == outcome) {</div>
<div class="line"><a name="l00833"></a><span class="lineno">  833</span>&#160; </div>
<div class="line"><a name="l00834"></a><span class="lineno">  834</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> outerDubBlockInd = 0; outerDubBlockInd &lt; numOuterDoubleBlocks; outerDubBlockInd++) {</div>
<div class="line"><a name="l00835"></a><span class="lineno">  835</span>&#160;            firstBlockInd = outerDubBlockInd*2*outerBlockSize;</div>
<div class="line"><a name="l00836"></a><span class="lineno">  836</span>&#160;            </div>
<div class="line"><a name="l00837"></a><span class="lineno">  837</span>&#160;            <span class="comment">// *norm only the desired inner blocks in the desired outer block</span></div>
<div class="line"><a name="l00838"></a><span class="lineno">  838</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0abdff5f6065f9d57065345e6d90fc94">alternateNormZeroingSomeAmpBlocks</a>(</div>
<div class="line"><a name="l00839"></a><span class="lineno">  839</span>&#160;                qureg, totalStateProb, innerBit==outcome, </div>
<div class="line"><a name="l00840"></a><span class="lineno">  840</span>&#160;                firstBlockInd, outerBlockSize, innerBlockSize);</div>
<div class="line"><a name="l00841"></a><span class="lineno">  841</span>&#160;            </div>
<div class="line"><a name="l00842"></a><span class="lineno">  842</span>&#160;            <span class="comment">// zero the undesired outer block</span></div>
<div class="line"><a name="l00843"></a><span class="lineno">  843</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ac5168399122f7f53977dcc9ceda4f458">zeroSomeAmps</a>(qureg, firstBlockInd + outerBlockSize, outerBlockSize);</div>
<div class="line"><a name="l00844"></a><span class="lineno">  844</span>&#160;        }</div>
<div class="line"><a name="l00845"></a><span class="lineno">  845</span>&#160; </div>
<div class="line"><a name="l00846"></a><span class="lineno">  846</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00847"></a><span class="lineno">  847</span>&#160; </div>
<div class="line"><a name="l00848"></a><span class="lineno">  848</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> outerDubBlockInd = 0; outerDubBlockInd &lt; numOuterDoubleBlocks; outerDubBlockInd++) {</div>
<div class="line"><a name="l00849"></a><span class="lineno">  849</span>&#160;            firstBlockInd = outerDubBlockInd*2*outerBlockSize;</div>
<div class="line"><a name="l00850"></a><span class="lineno">  850</span>&#160;            </div>
<div class="line"><a name="l00851"></a><span class="lineno">  851</span>&#160;            <span class="comment">// same thing but undesired outer blocks come first</span></div>
<div class="line"><a name="l00852"></a><span class="lineno">  852</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ac5168399122f7f53977dcc9ceda4f458">zeroSomeAmps</a>(qureg, firstBlockInd, outerBlockSize);</div>
<div class="line"><a name="l00853"></a><span class="lineno">  853</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0abdff5f6065f9d57065345e6d90fc94">alternateNormZeroingSomeAmpBlocks</a>(</div>
<div class="line"><a name="l00854"></a><span class="lineno">  854</span>&#160;                qureg, totalStateProb, innerBit==outcome, </div>
<div class="line"><a name="l00855"></a><span class="lineno">  855</span>&#160;                firstBlockInd + outerBlockSize, outerBlockSize, innerBlockSize);</div>
<div class="line"><a name="l00856"></a><span class="lineno">  856</span>&#160;        }</div>
<div class="line"><a name="l00857"></a><span class="lineno">  857</span>&#160;    }</div>
<div class="line"><a name="l00858"></a><span class="lineno">  858</span>&#160;    </div>
<div class="line"><a name="l00859"></a><span class="lineno">  859</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00754">alternateNormZeroingSomeAmpBlocks()</a>, <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00744">normaliseSomeAmps()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l00734">zeroSomeAmps()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00726">collapseToOutcome()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00369">densmatr_measureWithStats()</a>.</p>

</div>
</div>
<a id="a20a155f53efc45c16803d7539c2c199d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a20a155f53efc45c16803d7539c2c199d">&#9670;&nbsp;</a></span>densmatr_initClassicalState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_initClassicalState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>stateInd</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01115">1115</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01116"></a><span class="lineno"> 1116</span>&#160;{</div>
<div class="line"><a name="l01117"></a><span class="lineno"> 1117</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01118"></a><span class="lineno"> 1118</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> densityNumElems = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01119"></a><span class="lineno"> 1119</span>&#160; </div>
<div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *densityReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01122"></a><span class="lineno"> 1122</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *densityImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>&#160; </div>
<div class="line"><a name="l01124"></a><span class="lineno"> 1124</span>&#160;    <span class="comment">// initialise the state to all zeros</span></div>
<div class="line"><a name="l01125"></a><span class="lineno"> 1125</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01126"></a><span class="lineno"> 1126</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01128"></a><span class="lineno"> 1128</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>&#160;<span class="preprocessor">    shared   (densityNumElems, densityReal, densityImag) \</span></div>
<div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>&#160;    {</div>
<div class="line"><a name="l01133"></a><span class="lineno"> 1133</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01136"></a><span class="lineno"> 1136</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;densityNumElems; index++) {</div>
<div class="line"><a name="l01137"></a><span class="lineno"> 1137</span>&#160;            densityReal[index] = 0.0;</div>
<div class="line"><a name="l01138"></a><span class="lineno"> 1138</span>&#160;            densityImag[index] = 0.0;</div>
<div class="line"><a name="l01139"></a><span class="lineno"> 1139</span>&#160;        }</div>
<div class="line"><a name="l01140"></a><span class="lineno"> 1140</span>&#160;    }</div>
<div class="line"><a name="l01141"></a><span class="lineno"> 1141</span>&#160;    </div>
<div class="line"><a name="l01142"></a><span class="lineno"> 1142</span>&#160;    <span class="comment">// index of the single density matrix elem to set non-zero</span></div>
<div class="line"><a name="l01143"></a><span class="lineno"> 1143</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> densityDim = 1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l01144"></a><span class="lineno"> 1144</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> densityInd = (densityDim + 1)*stateInd;</div>
<div class="line"><a name="l01145"></a><span class="lineno"> 1145</span>&#160; </div>
<div class="line"><a name="l01146"></a><span class="lineno"> 1146</span>&#160;    <span class="comment">// give the specified classical state prob 1</span></div>
<div class="line"><a name="l01147"></a><span class="lineno"> 1147</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> == densityInd / densityNumElems){</div>
<div class="line"><a name="l01148"></a><span class="lineno"> 1148</span>&#160;        densityReal[densityInd % densityNumElems] = 1.0;</div>
<div class="line"><a name="l01149"></a><span class="lineno"> 1149</span>&#160;        densityImag[densityInd % densityNumElems] = 0.0;</div>
<div class="line"><a name="l01150"></a><span class="lineno"> 1150</span>&#160;    }</div>
<div class="line"><a name="l01151"></a><span class="lineno"> 1151</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00134">initClassicalState()</a>.</p>

</div>
</div>
<a id="a2418bd9a6b9e6a0acf11faf5982d5d29"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2418bd9a6b9e6a0acf11faf5982d5d29">&#9670;&nbsp;</a></span>densmatr_initPlusState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_initPlusState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>targetQureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01154">1154</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01155"></a><span class="lineno"> 1155</span>&#160;{</div>
<div class="line"><a name="l01156"></a><span class="lineno"> 1156</span>&#160;    <span class="comment">// |+&gt;&lt;+| = sum_i 1/sqrt(2^N) |i&gt; 1/sqrt(2^N) &lt;j| = sum_ij 1/2^N |i&gt;&lt;j|</span></div>
<div class="line"><a name="l01157"></a><span class="lineno"> 1157</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> dim = (1LL &lt;&lt; qureg.numQubitsRepresented);</div>
<div class="line"><a name="l01158"></a><span class="lineno"> 1158</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> probFactor = 1.0/((<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>) dim);</div>
<div class="line"><a name="l01159"></a><span class="lineno"> 1159</span>&#160; </div>
<div class="line"><a name="l01160"></a><span class="lineno"> 1160</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01161"></a><span class="lineno"> 1161</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *densityReal = qureg.stateVec.real;</div>
<div class="line"><a name="l01162"></a><span class="lineno"> 1162</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *densityImag = qureg.stateVec.imag;</div>
<div class="line"><a name="l01163"></a><span class="lineno"> 1163</span>&#160; </div>
<div class="line"><a name="l01164"></a><span class="lineno"> 1164</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01165"></a><span class="lineno"> 1165</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize = qureg.numAmpsPerChunk;</div>
<div class="line"><a name="l01166"></a><span class="lineno"> 1166</span>&#160;    <span class="comment">// initialise the state to |+++..+++&gt; = 1/normFactor {1, 1, 1, ...}</span></div>
<div class="line"><a name="l01167"></a><span class="lineno"> 1167</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01168"></a><span class="lineno"> 1168</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01169"></a><span class="lineno"> 1169</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01170"></a><span class="lineno"> 1170</span>&#160;<span class="preprocessor">    shared   (chunkSize, densityReal, densityImag, probFactor) \</span></div>
<div class="line"><a name="l01171"></a><span class="lineno"> 1171</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01172"></a><span class="lineno"> 1172</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01173"></a><span class="lineno"> 1173</span>&#160;    {</div>
<div class="line"><a name="l01174"></a><span class="lineno"> 1174</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01175"></a><span class="lineno"> 1175</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01176"></a><span class="lineno"> 1176</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01177"></a><span class="lineno"> 1177</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;chunkSize; index++) {</div>
<div class="line"><a name="l01178"></a><span class="lineno"> 1178</span>&#160;            densityReal[index] = probFactor;</div>
<div class="line"><a name="l01179"></a><span class="lineno"> 1179</span>&#160;            densityImag[index] = 0.0;</div>
<div class="line"><a name="l01180"></a><span class="lineno"> 1180</span>&#160;        }</div>
<div class="line"><a name="l01181"></a><span class="lineno"> 1181</span>&#160;    }</div>
<div class="line"><a name="l01182"></a><span class="lineno"> 1182</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00125">initPlusState()</a>.</p>

</div>
</div>
<a id="ae5ad68d054875913d0f7ec654840a9ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae5ad68d054875913d0f7ec654840a9ec">&#9670;&nbsp;</a></span>densmatr_initPureState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_initPureState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>targetQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>copyQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00452">452</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;                                                                {</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160; </div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;    <span class="keywordflow">if</span> (targetQureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>==1){</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;        <span class="comment">// local version</span></div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;        <span class="comment">// save pointers to qureg&#39;s pair state</span></div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* quregPairRePtr = targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real;</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* quregPairImPtr = targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag;</div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160; </div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;        <span class="comment">// populate qureg pair state with pure state (by repointing)</span></div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real = copyQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag = copyQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160; </div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;        <span class="comment">// populate density matrix via it&#39;s pairState</span></div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a>(targetQureg, copyQureg);</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160; </div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;        <span class="comment">// restore pointers</span></div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real = quregPairRePtr;</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag = quregPairImPtr;</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;        <span class="comment">// set qureg&#39;s pairState is to be the full pure state (on every node)</span></div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a>(targetQureg, copyQureg);</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;        </div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;        <span class="comment">// update every density matrix chunk using pairState</span></div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a>(targetQureg, copyQureg);</div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;    }</div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00371">copyVecIntoMatrixPairState()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01184">densmatr_initPureStateLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00145">initPureState()</a>.</p>

</div>
</div>
<a id="ae4ebc1f4dd48922bfb30ad1692310269"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae4ebc1f4dd48922bfb30ad1692310269">&#9670;&nbsp;</a></span>densmatr_measureWithStats()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int densmatr_measureWithStats </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>outcomeProb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00369">369</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;                                                                                 {</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;    </div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> zeroProb = <a class="code" href="QuEST__internal_8h.html#ae37b3eff5d3affbc1edfe216cabc1c53">densmatr_calcProbOfOutcome</a>(qureg, measureQubit, 0);</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;    <span class="keywordtype">int</span> outcome = <a class="code" href="QuEST__common_8c.html#a9d19fc690afb425d0df5feb09be567a3">generateMeasurementOutcome</a>(zeroProb, outcomeProb);</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a>(qureg, measureQubit, outcome, *outcomeProb);</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;    <span class="keywordflow">return</span> outcome;</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01276">densmatr_calcProbOfOutcome()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00785">densmatr_collapseToKnownProbOutcome()</a>, <a class="el" href="QuEST__common_8c_source.html#l00155">generateMeasurementOutcome()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00758">measure()</a>, and <a class="el" href="QuEST_8c_source.html#l00745">measureWithStats()</a>.</p>

</div>
</div>
<a id="ac501fe7b9d331be48359ce1546348f97"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac501fe7b9d331be48359ce1546348f97">&#9670;&nbsp;</a></span>densmatr_mixDamping()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixDamping </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>damping</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">725</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00725"></a><span class="lineno">  725</span>&#160;                                                                      {</div>
<div class="line"><a name="l00726"></a><span class="lineno">  726</span>&#160;    <span class="keywordflow">if</span> (damping == 0)</div>
<div class="line"><a name="l00727"></a><span class="lineno">  727</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00728"></a><span class="lineno">  728</span>&#160;    </div>
<div class="line"><a name="l00729"></a><span class="lineno">  729</span>&#160;    <span class="keywordtype">int</span> rankIsUpper; <span class="comment">// rank is in the upper half of an outer block</span></div>
<div class="line"><a name="l00730"></a><span class="lineno">  730</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00731"></a><span class="lineno">  731</span>&#160; </div>
<div class="line"><a name="l00732"></a><span class="lineno">  732</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00733"></a><span class="lineno">  733</span>&#160;            qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, targetQubit);</div>
<div class="line"><a name="l00734"></a><span class="lineno">  734</span>&#160; </div>
<div class="line"><a name="l00735"></a><span class="lineno">  735</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00736"></a><span class="lineno">  736</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab124a3a9956046bf9c0e1e3ae9171f42">densmatr_mixDampingLocal</a>(qureg, targetQubit, damping);</div>
<div class="line"><a name="l00737"></a><span class="lineno">  737</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00738"></a><span class="lineno">  738</span>&#160;        <span class="comment">// pack data to send to my pair process into the first half of pairStateVec</span></div>
<div class="line"><a name="l00739"></a><span class="lineno">  739</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a>(qureg, targetQubit);</div>
<div class="line"><a name="l00740"></a><span class="lineno">  740</span>&#160; </div>
<div class="line"><a name="l00741"></a><span class="lineno">  741</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit, </div>
<div class="line"><a name="l00742"></a><span class="lineno">  742</span>&#160;                qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00743"></a><span class="lineno">  743</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00744"></a><span class="lineno">  744</span>&#160;                targetQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00745"></a><span class="lineno">  745</span>&#160; </div>
<div class="line"><a name="l00746"></a><span class="lineno">  746</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00747"></a><span class="lineno">  747</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a8d9c19a3424f0ad89bfbfd920d65301d">densmatr_mixDampingDistributed</a>(qureg, targetQubit, damping);</div>
<div class="line"><a name="l00748"></a><span class="lineno">  748</span>&#160;    }</div>
<div class="line"><a name="l00749"></a><span class="lineno">  749</span>&#160; </div>
<div class="line"><a name="l00750"></a><span class="lineno">  750</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">chunkIsUpperInOuterBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00543">compressPairVectorForSingleQubitDepolarise()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">densityMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00300">densmatr_mixDampingDistributed()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00174">densmatr_mixDampingLocal()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l02609">densmatr_oneQubitDegradeOffDiagonal()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">exchangePairStateVectorHalves()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01034">mixDamping()</a>.</p>

</div>
</div>
<a id="a8adaba9dbdad6f7ab41ae4b8db0abefe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8adaba9dbdad6f7ab41ae4b8db0abefe">&#9670;&nbsp;</a></span>densmatr_mixDensityMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixDensityMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>combineQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>otherProb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>otherQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00890">890</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00890"></a><span class="lineno">  890</span>&#160;                                                                                      {</div>
<div class="line"><a name="l00891"></a><span class="lineno">  891</span>&#160;    </div>
<div class="line"><a name="l00892"></a><span class="lineno">  892</span>&#160;    <span class="comment">/* corresponding amplitudes live on the same node (same dimensions) */</span></div>
<div class="line"><a name="l00893"></a><span class="lineno">  893</span>&#160;    </div>
<div class="line"><a name="l00894"></a><span class="lineno">  894</span>&#160;    <span class="comment">// unpack vars for OpenMP</span></div>
<div class="line"><a name="l00895"></a><span class="lineno">  895</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* combineVecRe = combineQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00896"></a><span class="lineno">  896</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* combineVecIm = combineQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00897"></a><span class="lineno">  897</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* otherVecRe = otherQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00898"></a><span class="lineno">  898</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* otherVecIm = otherQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00899"></a><span class="lineno">  899</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = combineQureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00900"></a><span class="lineno">  900</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00901"></a><span class="lineno">  901</span>&#160;    </div>
<div class="line"><a name="l00902"></a><span class="lineno">  902</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00903"></a><span class="lineno">  903</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00904"></a><span class="lineno">  904</span>&#160;<span class="preprocessor">    default (none) \</span></div>
<div class="line"><a name="l00905"></a><span class="lineno">  905</span>&#160;<span class="preprocessor">    shared  (combineVecRe,combineVecIm,otherVecRe,otherVecIm, otherProb, numAmps) \</span></div>
<div class="line"><a name="l00906"></a><span class="lineno">  906</span>&#160;<span class="preprocessor">    private (index)</span></div>
<div class="line"><a name="l00907"></a><span class="lineno">  907</span>&#160;<span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00908"></a><span class="lineno">  908</span>&#160;    {</div>
<div class="line"><a name="l00909"></a><span class="lineno">  909</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00910"></a><span class="lineno">  910</span>&#160;<span class="preprocessor"># pragma omp for schedule  (static)</span></div>
<div class="line"><a name="l00911"></a><span class="lineno">  911</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00912"></a><span class="lineno">  912</span>&#160;        <span class="keywordflow">for</span> (index=0; index &lt; numAmps; index++) {</div>
<div class="line"><a name="l00913"></a><span class="lineno">  913</span>&#160;            combineVecRe[index] *= 1-otherProb;</div>
<div class="line"><a name="l00914"></a><span class="lineno">  914</span>&#160;            combineVecIm[index] *= 1-otherProb;</div>
<div class="line"><a name="l00915"></a><span class="lineno">  915</span>&#160;            </div>
<div class="line"><a name="l00916"></a><span class="lineno">  916</span>&#160;            combineVecRe[index] += otherProb * otherVecRe[index];</div>
<div class="line"><a name="l00917"></a><span class="lineno">  917</span>&#160;            combineVecIm[index] += otherProb * otherVecIm[index];</div>
<div class="line"><a name="l00918"></a><span class="lineno">  918</span>&#160;        }</div>
<div class="line"><a name="l00919"></a><span class="lineno">  919</span>&#160;    }</div>
<div class="line"><a name="l00920"></a><span class="lineno">  920</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00772">mixDensityMatrix()</a>.</p>

</div>
</div>
<a id="aa31f0ef43a921c3ac73545d1d3670fa1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa31f0ef43a921c3ac73545d1d3670fa1">&#9670;&nbsp;</a></span>densmatr_mixDephasing()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixDephasing </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>dephase</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00079">79</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;                                                                        {</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> retain=1-dephase;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#a717a0448066831cb5b392bcf2e1d0529">densmatr_oneQubitDegradeOffDiagonal</a>(qureg, targetQubit, retain);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00048">densmatr_oneQubitDegradeOffDiagonal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__gpu_8cu_source.html#l02752">densmatr_mixDepolarising()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00224">densmatr_mixDepolarisingDistributed()</a>, and <a class="el" href="QuEST_8c_source.html#l01001">mixDephasing()</a>.</p>

</div>
</div>
<a id="a398b60c4cb4fa2cf2ffc126de6c08da0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a398b60c4cb4fa2cf2ffc126de6c08da0">&#9670;&nbsp;</a></span>densmatr_mixDepolarising()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixDepolarising </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>depolLevel</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">698</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00698"></a><span class="lineno">  698</span>&#160;                                                                              {</div>
<div class="line"><a name="l00699"></a><span class="lineno">  699</span>&#160;    <span class="keywordflow">if</span> (depolLevel == 0)</div>
<div class="line"><a name="l00700"></a><span class="lineno">  700</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00701"></a><span class="lineno">  701</span>&#160;    </div>
<div class="line"><a name="l00702"></a><span class="lineno">  702</span>&#160;    <span class="keywordtype">int</span> rankIsUpper; <span class="comment">// rank is in the upper half of an outer block</span></div>
<div class="line"><a name="l00703"></a><span class="lineno">  703</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00704"></a><span class="lineno">  704</span>&#160; </div>
<div class="line"><a name="l00705"></a><span class="lineno">  705</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00706"></a><span class="lineno">  706</span>&#160;            qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, targetQubit);</div>
<div class="line"><a name="l00707"></a><span class="lineno">  707</span>&#160; </div>
<div class="line"><a name="l00708"></a><span class="lineno">  708</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00709"></a><span class="lineno">  709</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab750fb47da2fca9849c678c869e40e69">densmatr_mixDepolarisingLocal</a>(qureg, targetQubit, depolLevel);</div>
<div class="line"><a name="l00710"></a><span class="lineno">  710</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00711"></a><span class="lineno">  711</span>&#160;        <span class="comment">// pack data to send to my pair process into the first half of pairStateVec</span></div>
<div class="line"><a name="l00712"></a><span class="lineno">  712</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a>(qureg, targetQubit);</div>
<div class="line"><a name="l00713"></a><span class="lineno">  713</span>&#160; </div>
<div class="line"><a name="l00714"></a><span class="lineno">  714</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit, </div>
<div class="line"><a name="l00715"></a><span class="lineno">  715</span>&#160;                qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00716"></a><span class="lineno">  716</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00717"></a><span class="lineno">  717</span>&#160;                targetQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00718"></a><span class="lineno">  718</span>&#160; </div>
<div class="line"><a name="l00719"></a><span class="lineno">  719</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00720"></a><span class="lineno">  720</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a88670d0e7cebe33f61c1dd98daa338b3">densmatr_mixDepolarisingDistributed</a>(qureg, targetQubit, depolLevel);</div>
<div class="line"><a name="l00721"></a><span class="lineno">  721</span>&#160;    }</div>
<div class="line"><a name="l00722"></a><span class="lineno">  722</span>&#160; </div>
<div class="line"><a name="l00723"></a><span class="lineno">  723</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">chunkIsUpperInOuterBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00543">compressPairVectorForSingleQubitDepolarise()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">densityMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l02629">densmatr_mixDephasing()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00224">densmatr_mixDepolarisingDistributed()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00125">densmatr_mixDepolarisingLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">exchangePairStateVectorHalves()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01023">mixDepolarising()</a>.</p>

</div>
</div>
<a id="ab987904f721746d1176aba7ac6b566fa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab987904f721746d1176aba7ac6b566fa">&#9670;&nbsp;</a></span>densmatr_mixKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixKrausMap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> *&#160;</td>
          <td class="paramname"><em>ops</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00600">600</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00600"></a><span class="lineno">  600</span>&#160;                                                                                    {</div>
<div class="line"><a name="l00601"></a><span class="lineno">  601</span>&#160;        </div>
<div class="line"><a name="l00602"></a><span class="lineno">  602</span>&#160;    <a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a> superOp; </div>
<div class="line"><a name="l00603"></a><span class="lineno">  603</span>&#160;    <a class="code" href="QuEST__common_8c.html#abd00ba1321c9bd43c3a9119f5b3ed1be">populateKrausSuperOperator2</a>(&amp;superOp, ops, numOps);</div>
<div class="line"><a name="l00604"></a><span class="lineno">  604</span>&#160;    <a class="code" href="QuEST__common_8c.html#af3db21114efc431ae7a7ae06fc2d7b5b">densmatr_applyKrausSuperoperator</a>(qureg, target, superOp);</div>
<div class="line"><a name="l00605"></a><span class="lineno">  605</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00576">densmatr_applyKrausSuperoperator()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00563">populateKrausSuperOperator2()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__common_8c_source.html#l00676">densmatr_mixPauli()</a>, and <a class="el" href="QuEST_8c_source.html#l01065">mixKrausMap()</a>.</p>

</div>
</div>
<a id="a99702f4667c429969d7e7b4ecd45c2f3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a99702f4667c429969d7e7b4ecd45c2f3">&#9670;&nbsp;</a></span>densmatr_mixMultiQubitKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixMultiQubitKrausMap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> *&#160;</td>
          <td class="paramname"><em>ops</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00643">643</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00643"></a><span class="lineno">  643</span>&#160;                                                                                                                {</div>
<div class="line"><a name="l00644"></a><span class="lineno">  644</span>&#160; </div>
<div class="line"><a name="l00645"></a><span class="lineno">  645</span>&#160;    <a class="code" href="structComplexMatrixN.html">ComplexMatrixN</a> superOp;</div>
<div class="line"><a name="l00646"></a><span class="lineno">  646</span>&#160;    </div>
<div class="line"><a name="l00647"></a><span class="lineno">  647</span>&#160;    <span class="comment">/* superOp will contain 2^(4 numTargets) complex numbers.</span></div>
<div class="line"><a name="l00648"></a><span class="lineno">  648</span>&#160;<span class="comment">     * At double precision, superOp will cost additional memory:</span></div>
<div class="line"><a name="l00649"></a><span class="lineno">  649</span>&#160;<span class="comment">     * numTargs=1   -&gt;   0.25 KiB</span></div>
<div class="line"><a name="l00650"></a><span class="lineno">  650</span>&#160;<span class="comment">     * numTargs=2   -&gt;   4 KiB </span></div>
<div class="line"><a name="l00651"></a><span class="lineno">  651</span>&#160;<span class="comment">     * numTargs=3   -&gt;   64 KiB</span></div>
<div class="line"><a name="l00652"></a><span class="lineno">  652</span>&#160;<span class="comment">     * numTargs=4   -&gt;   1 MiB</span></div>
<div class="line"><a name="l00653"></a><span class="lineno">  653</span>&#160;<span class="comment">     * numTargs=5   -&gt;   16 MiB.</span></div>
<div class="line"><a name="l00654"></a><span class="lineno">  654</span>&#160;<span class="comment">     * At quad precision (usually 10 B per number, but possibly 16 B due to alignment),</span></div>
<div class="line"><a name="l00655"></a><span class="lineno">  655</span>&#160;<span class="comment">     * this costs at most double.</span></div>
<div class="line"><a name="l00656"></a><span class="lineno">  656</span>&#160;<span class="comment">     *</span></div>
<div class="line"><a name="l00657"></a><span class="lineno">  657</span>&#160;<span class="comment">     * Hence, if superOp is kept in the stack, numTargs &gt;= 4 would exceed Windows&#39; 1 MB </span></div>
<div class="line"><a name="l00658"></a><span class="lineno">  658</span>&#160;<span class="comment">     * maximum stack-space allocation (numTargs &gt;= 5 exceeding Linux&#39; 8 MB). Therefore, </span></div>
<div class="line"><a name="l00659"></a><span class="lineno">  659</span>&#160;<span class="comment">     * for numTargets &lt; 4, superOp will be kept in the stack, else in the heap</span></div>
<div class="line"><a name="l00660"></a><span class="lineno">  660</span>&#160;<span class="comment">     */</span></div>
<div class="line"><a name="l00661"></a><span class="lineno">  661</span>&#160;     </div>
<div class="line"><a name="l00662"></a><span class="lineno">  662</span>&#160;    <span class="keywordflow">if</span> (numTargets &lt; 4) {</div>
<div class="line"><a name="l00663"></a><span class="lineno">  663</span>&#160;        <span class="comment">// everything must live in &#39;if&#39; since this macro declares local vars</span></div>
<div class="line"><a name="l00664"></a><span class="lineno">  664</span>&#160;        <a class="code" href="QuEST__common_8c.html#a4da103b16292ffd99197d05c5fa83712">macro_allocStackComplexMatrixN</a>(superOp, 2*numTargets);</div>
<div class="line"><a name="l00665"></a><span class="lineno">  665</span>&#160;        <a class="code" href="QuEST__common_8c.html#a6dcb85ef8e1257813af0dc306082caf8">populateKrausSuperOperatorN</a>(&amp;superOp, ops, numOps);</div>
<div class="line"><a name="l00666"></a><span class="lineno">  666</span>&#160;        <a class="code" href="QuEST__common_8c.html#a514ca44595676abf4bc2e10fc48ef970">densmatr_applyMultiQubitKrausSuperoperator</a>(qureg, targets, numTargets, superOp);</div>
<div class="line"><a name="l00667"></a><span class="lineno">  667</span>&#160;    }</div>
<div class="line"><a name="l00668"></a><span class="lineno">  668</span>&#160;    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00669"></a><span class="lineno">  669</span>&#160;        superOp = <a class="code" href="group__type.html#ga815103261fb22ea9690e1427571df00e">createComplexMatrixN</a>(2*numTargets);</div>
<div class="line"><a name="l00670"></a><span class="lineno">  670</span>&#160;        <a class="code" href="QuEST__common_8c.html#a6dcb85ef8e1257813af0dc306082caf8">populateKrausSuperOperatorN</a>(&amp;superOp, ops, numOps);</div>
<div class="line"><a name="l00671"></a><span class="lineno">  671</span>&#160;        <a class="code" href="QuEST__common_8c.html#a514ca44595676abf4bc2e10fc48ef970">densmatr_applyMultiQubitKrausSuperoperator</a>(qureg, targets, numTargets, superOp);</div>
<div class="line"><a name="l00672"></a><span class="lineno">  672</span>&#160;        <a class="code" href="group__type.html#ga9df2f3d86be4a6e9aad481665e5e6753">destroyComplexMatrixN</a>(superOp);</div>
<div class="line"><a name="l00673"></a><span class="lineno">  673</span>&#160;    }</div>
<div class="line"><a name="l00674"></a><span class="lineno">  674</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8c_source.html#l01099">createComplexMatrixN()</a>, <a class="el" href="QuEST__common_8c_source.html#l00590">densmatr_applyMultiQubitKrausSuperoperator()</a>, <a class="el" href="QuEST_8c_source.html#l01120">destroyComplexMatrixN()</a>, <a class="el" href="QuEST__common_8c_source.html#l00629">macro_allocStackComplexMatrixN</a>, and <a class="el" href="QuEST__common_8c_source.html#l00571">populateKrausSuperOperatorN()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01085">mixMultiQubitKrausMap()</a>.</p>

</div>
</div>
<a id="a74c14b1c46d838f5bf2bed1d5cf63271"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a74c14b1c46d838f5bf2bed1d5cf63271">&#9670;&nbsp;</a></span>densmatr_mixPauli()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixPauli </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>pX</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>pY</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>pZ</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00676">676</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00676"></a><span class="lineno">  676</span>&#160;                                                                                      {</div>
<div class="line"><a name="l00677"></a><span class="lineno">  677</span>&#160;    </div>
<div class="line"><a name="l00678"></a><span class="lineno">  678</span>&#160;    <span class="comment">// convert pauli probabilities into Kraus map</span></div>
<div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">int</span> numOps = 4;</div>
<div class="line"><a name="l00680"></a><span class="lineno">  680</span>&#160;    <a class="code" href="structComplexMatrix2.html">ComplexMatrix2</a> ops[numOps];</div>
<div class="line"><a name="l00681"></a><span class="lineno">  681</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n=0; n &lt; numOps; n++)</div>
<div class="line"><a name="l00682"></a><span class="lineno">  682</span>&#160;        ops[n] = (<a class="code" href="structComplexMatrix2.html">ComplexMatrix2</a>) {.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>={{0}}, .imag={{0}}};</div>
<div class="line"><a name="l00683"></a><span class="lineno">  683</span>&#160;    </div>
<div class="line"><a name="l00684"></a><span class="lineno">  684</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facs[4] = { <span class="comment">// literal numOps=4 for valid initialisation</span></div>
<div class="line"><a name="l00685"></a><span class="lineno">  685</span>&#160;                sqrt(1-(probX + probY + probZ)),</div>
<div class="line"><a name="l00686"></a><span class="lineno">  686</span>&#160;                sqrt(probX),</div>
<div class="line"><a name="l00687"></a><span class="lineno">  687</span>&#160;                sqrt(probY),</div>
<div class="line"><a name="l00688"></a><span class="lineno">  688</span>&#160;                sqrt(probZ)</div>
<div class="line"><a name="l00689"></a><span class="lineno">  689</span>&#160;        };</div>
<div class="line"><a name="l00690"></a><span class="lineno">  690</span>&#160;    ops[0].<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][0] =  facs[0]; ops[0].<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][1] =  facs[0];</div>
<div class="line"><a name="l00691"></a><span class="lineno">  691</span>&#160;    ops[1].<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][1] =  facs[1]; ops[1].<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][0] =  facs[1];</div>
<div class="line"><a name="l00692"></a><span class="lineno">  692</span>&#160;    ops[2].<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[0][1] = -facs[2]; ops[2].<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[1][0] =  facs[2];</div>
<div class="line"><a name="l00693"></a><span class="lineno">  693</span>&#160;    ops[3].<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][0] =  facs[3]; ops[3].<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][1] = -facs[3];</div>
<div class="line"><a name="l00694"></a><span class="lineno">  694</span>&#160;    </div>
<div class="line"><a name="l00695"></a><span class="lineno">  695</span>&#160;    <a class="code" href="QuEST__common_8c.html#ab987904f721746d1176aba7ac6b566fa">densmatr_mixKrausMap</a>(qureg, qubit, ops, numOps);</div>
<div class="line"><a name="l00696"></a><span class="lineno">  696</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00600">densmatr_mixKrausMap()</a>, <a class="el" href="QuEST_8h_source.html#l00117">ComplexMatrix2::imag</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00116">ComplexMatrix2::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01054">mixPauli()</a>.</p>

</div>
</div>
<a id="a623e577b7230f3c8dc202be6185b4289"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a623e577b7230f3c8dc202be6185b4289">&#9670;&nbsp;</a></span>densmatr_mixTwoQubitDephasing()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixTwoQubitDephasing </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>dephase</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00084">84</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;                                                                                       {</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> retain=1-dephase;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numTasks = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> innerMaskQubit1 = 1LL &lt;&lt; qubit1;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> outerMaskQubit1 = 1LL &lt;&lt; (qubit1 + (qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>));</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> innerMaskQubit2 = 1LL &lt;&lt; qubit2;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> outerMaskQubit2 = 1LL &lt;&lt; (qubit2 + (qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>));</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> totMaskQubit1 = innerMaskQubit1|outerMaskQubit1;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> totMaskQubit2 = innerMaskQubit2|outerMaskQubit2;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisTask;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisPatternQubit1, thisPatternQubit2;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="preprocessor">    shared   (innerMaskQubit1,outerMaskQubit1,totMaskQubit1,innerMaskQubit2,outerMaskQubit2, \</span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="preprocessor">                totMaskQubit2,qureg,retain,numTasks) \</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;<span class="preprocessor">    private  (thisTask,thisPatternQubit1,thisPatternQubit2)</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    {</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        <span class="keywordflow">for</span> (thisTask=0; thisTask&lt;numTasks; thisTask++){</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;            thisPatternQubit1 = (thisTask+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>)&amp;totMaskQubit1;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;            thisPatternQubit2 = (thisTask+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>)&amp;totMaskQubit2;</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;            </div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;            <span class="comment">// any mismatch |...0...&gt;&lt;...1...| etc</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;            <span class="keywordflow">if</span> ( (thisPatternQubit1==innerMaskQubit1) || (thisPatternQubit1==outerMaskQubit1) || </div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;                    (thisPatternQubit2==innerMaskQubit2) || (thisPatternQubit2==outerMaskQubit2) ){ </div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;                <span class="comment">// do dephase</span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;                <span class="comment">// the lines below will degrade the off-diagonal terms |..0..&gt;&lt;..1..| and |..1..&gt;&lt;..0..|</span></div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisTask] = retain*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisTask]; </div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisTask] = retain*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisTask]; </div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;            } </div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        }  </div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    }</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>, and <a class="el" href="QuEST_8c_source.html#l01011">mixTwoQubitDephasing()</a>.</p>

</div>
</div>
<a id="a43afa97e300b87bce7f3eb1213eb05f6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a43afa97e300b87bce7f3eb1213eb05f6">&#9670;&nbsp;</a></span>densmatr_mixTwoQubitDepolarising()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixTwoQubitDepolarising </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>depolLevel</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">752</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00752"></a><span class="lineno">  752</span>&#160;                                                                                            {</div>
<div class="line"><a name="l00753"></a><span class="lineno">  753</span>&#160;    <span class="keywordflow">if</span> (depolLevel == 0)</div>
<div class="line"><a name="l00754"></a><span class="lineno">  754</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00755"></a><span class="lineno">  755</span>&#160;    <span class="keywordtype">int</span> rankIsUpperBiggerQubit, rankIsUpperSmallerQubit;</div>
<div class="line"><a name="l00756"></a><span class="lineno">  756</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00757"></a><span class="lineno">  757</span>&#160;    <span class="keywordtype">int</span> biggerQubit, smallerQubit;</div>
<div class="line"><a name="l00758"></a><span class="lineno">  758</span>&#160; </div>
<div class="line"><a name="l00759"></a><span class="lineno">  759</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a>(qureg, qubit1, qubit2, depolLevel);</div>
<div class="line"><a name="l00760"></a><span class="lineno">  760</span>&#160;    </div>
<div class="line"><a name="l00761"></a><span class="lineno">  761</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> eta = 2/depolLevel;</div>
<div class="line"><a name="l00762"></a><span class="lineno">  762</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> delta = eta - 1 - sqrt( (eta-1)*(eta-1) - 1 ); </div>
<div class="line"><a name="l00763"></a><span class="lineno">  763</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> gamma = 1+delta;</div>
<div class="line"><a name="l00764"></a><span class="lineno">  764</span>&#160;    gamma = 1/(gamma*gamma*gamma);</div>
<div class="line"><a name="l00765"></a><span class="lineno">  765</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> GAMMA_PARTS_1_OR_2 = 1.0;</div>
<div class="line"><a name="l00766"></a><span class="lineno">  766</span>&#160;    <span class="comment">// TODO -- test delta too small</span></div>
<div class="line"><a name="l00767"></a><span class="lineno">  767</span>&#160;    <span class="comment">/*   </span></div>
<div class="line"><a name="l00768"></a><span class="lineno">  768</span>&#160;<span class="comment">    if (fabs(4*delta*(1+delta)*gamma-depolLevel)&gt;1e-5){</span></div>
<div class="line"><a name="l00769"></a><span class="lineno">  769</span>&#160;<span class="comment">        printf(&quot;Numerical error in delta; for small error rates try Taylor expansion.\n&quot;);</span></div>
<div class="line"><a name="l00770"></a><span class="lineno">  770</span>&#160;<span class="comment">        exit(1);</span></div>
<div class="line"><a name="l00771"></a><span class="lineno">  771</span>&#160;<span class="comment">    }</span></div>
<div class="line"><a name="l00772"></a><span class="lineno">  772</span>&#160;<span class="comment">    */</span></div>
<div class="line"><a name="l00773"></a><span class="lineno">  773</span>&#160;    </div>
<div class="line"><a name="l00774"></a><span class="lineno">  774</span>&#160;    biggerQubit = qubit1 &gt; qubit2 ? qubit1 : qubit2;</div>
<div class="line"><a name="l00775"></a><span class="lineno">  775</span>&#160;    smallerQubit = qubit1 &lt; qubit2 ? qubit1 : qubit2;</div>
<div class="line"><a name="l00776"></a><span class="lineno">  776</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnlyBigQubit, useLocalDataOnlySmallQubit;</div>
<div class="line"><a name="l00777"></a><span class="lineno">  777</span>&#160; </div>
<div class="line"><a name="l00778"></a><span class="lineno">  778</span>&#160;    useLocalDataOnlyBigQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00779"></a><span class="lineno">  779</span>&#160;        qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, biggerQubit);</div>
<div class="line"><a name="l00780"></a><span class="lineno">  780</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnlyBigQubit){</div>
<div class="line"><a name="l00781"></a><span class="lineno">  781</span>&#160;        <span class="comment">// does parts 1, 2 and 3 locally in one go</span></div>
<div class="line"><a name="l00782"></a><span class="lineno">  782</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a3510f01d4d15dcc545564eb84c668cad">densmatr_mixTwoQubitDepolarisingLocal</a>(qureg, qubit1, qubit2, delta, gamma);</div>
<div class="line"><a name="l00783"></a><span class="lineno">  783</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00784"></a><span class="lineno">  784</span>&#160;        useLocalDataOnlySmallQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00785"></a><span class="lineno">  785</span>&#160;            qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, smallerQubit);</div>
<div class="line"><a name="l00786"></a><span class="lineno">  786</span>&#160;        <span class="keywordflow">if</span> (useLocalDataOnlySmallQubit){</div>
<div class="line"><a name="l00787"></a><span class="lineno">  787</span>&#160;            <span class="comment">// do part 1 locally</span></div>
<div class="line"><a name="l00788"></a><span class="lineno">  788</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ae90f82418e0aa67218d733dbbc681998">densmatr_mixTwoQubitDepolarisingLocalPart1</a>(qureg, smallerQubit, biggerQubit, delta);</div>
<div class="line"><a name="l00789"></a><span class="lineno">  789</span>&#160;            </div>
<div class="line"><a name="l00790"></a><span class="lineno">  790</span>&#160;            <span class="comment">// do parts 2 and 3 distributed (if part 2 is distributed part 3 is also distributed)</span></div>
<div class="line"><a name="l00791"></a><span class="lineno">  791</span>&#160;            <span class="comment">// part 2 will be distributed and the value of the small qubit won&#39;t matter</span></div>
<div class="line"><a name="l00792"></a><span class="lineno">  792</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00793"></a><span class="lineno">  793</span>&#160;            rankIsUpperBiggerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, biggerQubit, </div>
<div class="line"><a name="l00794"></a><span class="lineno">  794</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00795"></a><span class="lineno">  795</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperBiggerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00796"></a><span class="lineno">  796</span>&#160;                    biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00797"></a><span class="lineno">  797</span>&#160; </div>
<div class="line"><a name="l00798"></a><span class="lineno">  798</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00799"></a><span class="lineno">  799</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, GAMMA_PARTS_1_OR_2);</div>
<div class="line"><a name="l00800"></a><span class="lineno">  800</span>&#160;            </div>
<div class="line"><a name="l00801"></a><span class="lineno">  801</span>&#160;            <span class="comment">// part 3 will be distributed but involve rearranging for the smaller qubit</span></div>
<div class="line"><a name="l00802"></a><span class="lineno">  802</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00803"></a><span class="lineno">  803</span>&#160;            rankIsUpperBiggerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, biggerQubit, </div>
<div class="line"><a name="l00804"></a><span class="lineno">  804</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00805"></a><span class="lineno">  805</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperBiggerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;                    biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160; </div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00809"></a><span class="lineno">  809</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#acabdfbd3184d3ab3bded61e24142b800">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3</a>(qureg, smallerQubit, biggerQubit, delta, gamma);</div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;            <span class="comment">// do part 1, 2 and 3 distributed</span></div>
<div class="line"><a name="l00812"></a><span class="lineno">  812</span>&#160;            <span class="comment">// part 1</span></div>
<div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;            rankIsUpperSmallerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, smallerQubit, </div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00816"></a><span class="lineno">  816</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperSmallerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00817"></a><span class="lineno">  817</span>&#160;                    smallerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00818"></a><span class="lineno">  818</span>&#160; </div>
<div class="line"><a name="l00819"></a><span class="lineno">  819</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00820"></a><span class="lineno">  820</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, GAMMA_PARTS_1_OR_2);</div>
<div class="line"><a name="l00821"></a><span class="lineno">  821</span>&#160; </div>
<div class="line"><a name="l00822"></a><span class="lineno">  822</span>&#160;            <span class="comment">// part 2</span></div>
<div class="line"><a name="l00823"></a><span class="lineno">  823</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00824"></a><span class="lineno">  824</span>&#160;            rankIsUpperBiggerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, biggerQubit, </div>
<div class="line"><a name="l00825"></a><span class="lineno">  825</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00826"></a><span class="lineno">  826</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperBiggerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00827"></a><span class="lineno">  827</span>&#160;                    biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00828"></a><span class="lineno">  828</span>&#160; </div>
<div class="line"><a name="l00829"></a><span class="lineno">  829</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00830"></a><span class="lineno">  830</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, GAMMA_PARTS_1_OR_2);</div>
<div class="line"><a name="l00831"></a><span class="lineno">  831</span>&#160; </div>
<div class="line"><a name="l00832"></a><span class="lineno">  832</span>&#160;            <span class="comment">// part 3</span></div>
<div class="line"><a name="l00833"></a><span class="lineno">  833</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00834"></a><span class="lineno">  834</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ab1ec7f241b68b079c8e316d190af49ce">getChunkOuterBlockPairIdForPart3</a>(rankIsUpperSmallerQubit, rankIsUpperBiggerQubit, </div>
<div class="line"><a name="l00835"></a><span class="lineno">  835</span>&#160;                    qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, smallerQubit, biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00836"></a><span class="lineno">  836</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00837"></a><span class="lineno">  837</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, gamma);</div>
<div class="line"><a name="l00838"></a><span class="lineno">  838</span>&#160; </div>
<div class="line"><a name="l00839"></a><span class="lineno">  839</span>&#160;        }</div>
<div class="line"><a name="l00840"></a><span class="lineno">  840</span>&#160;    }</div>
<div class="line"><a name="l00841"></a><span class="lineno">  841</span>&#160; </div>
<div class="line"><a name="l00842"></a><span class="lineno">  842</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">chunkIsUpperInOuterBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00610">compressPairVectorForTwoQubitDepolarise()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">densityMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00084">densmatr_mixTwoQubitDephasing()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00541">densmatr_mixTwoQubitDepolarisingDistributed()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00387">densmatr_mixTwoQubitDepolarisingLocal()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00488">densmatr_mixTwoQubitDepolarisingLocalPart1()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00632">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">exchangePairStateVectorHalves()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00325">getChunkOuterBlockPairIdForPart3()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01042">mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="ab004038b5f906ea897621c88bf213129"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab004038b5f906ea897621c88bf213129">&#9670;&nbsp;</a></span>densmatr_mixTwoQubitKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixTwoQubitKrausMap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> *&#160;</td>
          <td class="paramname"><em>ops</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00635">635</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00635"></a><span class="lineno">  635</span>&#160;                                                                                                          {</div>
<div class="line"><a name="l00636"></a><span class="lineno">  636</span>&#160;    </div>
<div class="line"><a name="l00637"></a><span class="lineno">  637</span>&#160;    <a class="code" href="structComplexMatrixN.html">ComplexMatrixN</a> superOp;</div>
<div class="line"><a name="l00638"></a><span class="lineno">  638</span>&#160;    <a class="code" href="QuEST__common_8c.html#a4da103b16292ffd99197d05c5fa83712">macro_allocStackComplexMatrixN</a>(superOp, 4);</div>
<div class="line"><a name="l00639"></a><span class="lineno">  639</span>&#160;    <a class="code" href="QuEST__common_8c.html#a2a6999e47bed978eb66f589c8abc7766">populateKrausSuperOperator4</a>(&amp;superOp, ops, numOps);</div>
<div class="line"><a name="l00640"></a><span class="lineno">  640</span>&#160;    <a class="code" href="QuEST__common_8c.html#a3d39314af5d88822d4aefb5e9cc4e2f6">densmatr_applyTwoQubitKrausSuperoperator</a>(qureg, target1, target2, superOp);</div>
<div class="line"><a name="l00641"></a><span class="lineno">  641</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00582">densmatr_applyTwoQubitKrausSuperoperator()</a>, <a class="el" href="QuEST__common_8c_source.html#l00629">macro_allocStackComplexMatrixN</a>, and <a class="el" href="QuEST__common_8c_source.html#l00567">populateKrausSuperOperator4()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01075">mixTwoQubitKrausMap()</a>.</p>

</div>
</div>
<a id="ac8ea84dd85eca525daeeb30b3c96b673"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac8ea84dd85eca525daeeb30b3c96b673">&#9670;&nbsp;</a></span>ensureIndsIncrease()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ensureIndsIncrease </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ind1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ind2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00064">64</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;                                              {</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    </div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="keywordflow">if</span> (*ind1 &gt; *ind2) {</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        <span class="keywordtype">int</span> copy = *ind1;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        *ind1 = *ind2;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        *ind2 = copy;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    }</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01011">mixTwoQubitDephasing()</a>, and <a class="el" href="QuEST_8c_source.html#l01042">mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="a73300e3cdca56a7615980274905ba097"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a73300e3cdca56a7615980274905ba097">&#9670;&nbsp;</a></span>getComplexPairAndPhaseFromUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void getComplexPairAndPhaseFromUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>beta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>globalPhase</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>maps U(r0c0, r0c1, r1c0, r1c1) to exp(i globalPhase) U(alpha, beta) </p>

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00136">136</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;                                                                                                            {</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    </div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> r0c0Phase = atan2(u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[0][0], u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][0]);</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> r1c1Phase = atan2(u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[1][1], u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][1]);</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    *globalPhase = (r0c0Phase + r1c1Phase)/2.0;</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    </div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> cosPhase = cos(*globalPhase);</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> sinPhase = sin(*globalPhase);</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    alpha-&gt;<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][0]*cosPhase + u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[0][0]*sinPhase;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    alpha-&gt;<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[0][0]*cosPhase - u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][0]*sinPhase;</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    beta-&gt;<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>  = u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][0]*cosPhase + u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[1][0]*sinPhase;</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    beta-&gt;<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>  = u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[1][0]*cosPhase - u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][0]*sinPhase;</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00117">ComplexMatrix2::imag</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST_8h_source.html#l00116">ComplexMatrix2::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__qasm_8c_source.html#l00278">qasm_recordControlledUnitary()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00341">qasm_recordMultiControlledUnitary()</a>, and <a class="el" href="QuEST__qasm_8c_source.html#l00207">qasm_recordUnitary()</a>.</p>

</div>
</div>
<a id="a71b3ae4402c1c5039d3086ca0e47a522"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a71b3ae4402c1c5039d3086ca0e47a522">&#9670;&nbsp;</a></span>getComplexPairFromRotation()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void getComplexPairFromRotation </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a>&#160;</td>
          <td class="paramname"><em>axis</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00114">114</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;                                                                                         {</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    </div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = <a class="code" href="QuEST__common_8c.html#a041bb75200ee316de7b90667a4fe04f3">getUnitVector</a>(axis);</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    alpha-&gt;<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> =   cos(angle/2.0);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    alpha-&gt;<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = - sin(angle/2.0)*unitAxis.<a class="code" href="structVector.html#ab33976d8fda2e44b770f71269d698a25">z</a>;  </div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    beta-&gt;<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>  =   sin(angle/2.0)*unitAxis.<a class="code" href="structVector.html#abc3cfc6c8e297b1153a373d84b981e6b">y</a>;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    beta-&gt;<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>  = - sin(angle/2.0)*unitAxis.<a class="code" href="structVector.html#a0d0459a5b731ac5fb3dff2c6134e6e88">x</a>;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00078">getUnitVector()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST_8h_source.html#l00150">Vector::x</a>, <a class="el" href="QuEST_8h_source.html#l00150">Vector::y</a>, and <a class="el" href="QuEST_8h_source.html#l00150">Vector::z</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__qasm_8c_source.html#l00223">qasm_recordAxisRotation()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00300">qasm_recordControlledAxisRotation()</a>, <a class="el" href="QuEST__common_8c_source.html#l00327">statevec_controlledRotateAroundAxis()</a>, <a class="el" href="QuEST__common_8c_source.html#l00334">statevec_controlledRotateAroundAxisConj()</a>, <a class="el" href="QuEST__common_8c_source.html#l00311">statevec_rotateAroundAxis()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00318">statevec_rotateAroundAxisConj()</a>.</p>

</div>
</div>
<a id="ad34d98eeaa6a3cb45e92c696cfd2d1c8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad34d98eeaa6a3cb45e92c696cfd2d1c8">&#9670;&nbsp;</a></span>getConjugateMatrix2()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> getConjugateMatrix2 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>src</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00099">99</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;                                                       {</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    <a class="code" href="structComplexMatrix2.html">ComplexMatrix2</a> conj;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <a class="code" href="QuEST__common_8c.html#ae2b222fda52c10fb420cb3ac78ca31e4">macro_setConjugateMatrix</a>(conj, src, 2);</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    <span class="keywordflow">return</span> conj;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00093">macro_setConjugateMatrix</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00361">controlledUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00374">multiControlledUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00389">multiStateControlledUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00349">unitary()</a>.</p>

</div>
</div>
<a id="a20d45e85dd49dd3bf6045990b590b24b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a20d45e85dd49dd3bf6045990b590b24b">&#9670;&nbsp;</a></span>getConjugateMatrix4()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> getConjugateMatrix4 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>src</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00104">104</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;                                                       {</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    <a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a> conj;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <a class="code" href="QuEST__common_8c.html#ae2b222fda52c10fb420cb3ac78ca31e4">macro_setConjugateMatrix</a>(conj, src, 4);</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keywordflow">return</span> conj;</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00093">macro_setConjugateMatrix</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00270">controlledTwoQubitUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00283">multiControlledTwoQubitUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00257">twoQubitUnitary()</a>.</p>

</div>
</div>
<a id="af92fa737f4491324408b3d15543dced4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af92fa737f4491324408b3d15543dced4">&#9670;&nbsp;</a></span>getConjugateScalar()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> getConjugateScalar </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>scalar</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00085">85</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;                                           {</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    </div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <a class="code" href="structComplex.html">Complex</a> conjScalar;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    conjScalar.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> =   scalar.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    conjScalar.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = - scalar.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordflow">return</span> conjScalar;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, and <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00405">compactUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00418">controlledCompactUnitary()</a>.</p>

</div>
</div>
<a id="a6fa6f1bc617e9fef3cd87ecc3677a02b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6fa6f1bc617e9fef3cd87ecc3677a02b">&#9670;&nbsp;</a></span>getControlFlipMask()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">long long int getControlFlipMask </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>controlQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>controlState</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numControlQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00054">54</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;                                                                                              {</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    </div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> mask=0;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numControlQubits; i++)</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="keywordflow">if</span> (controlState[i] == 0)</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;            mask = mask | (1LL &lt;&lt; controlQubits[i]);</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    <span class="keywordflow">return</span> mask;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00389">multiStateControlledUnitary()</a>.</p>

</div>
</div>
<a id="a0182eedcff44469771c971d8e2d73dc5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0182eedcff44469771c971d8e2d73dc5">&#9670;&nbsp;</a></span>getQubitBitMask()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">long long int getQubitBitMask </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>controlQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numControlQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00044">44</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;                                                          {</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    </div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> mask=0; </div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numQubits; i++)</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        mask = mask | (1LL &lt;&lt; qubits[i]);</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        </div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keywordflow">return</span> mask;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00874">applyMultiControlledMatrixN()</a>, <a class="el" href="QuEST_8c_source.html#l00331">multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00283">multiControlledTwoQubitUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00374">multiControlledUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00626">multiRotateZ()</a>, <a class="el" href="QuEST_8c_source.html#l00389">multiStateControlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">statevec_multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03331">statevec_multiControlledPhaseFlip()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03059">statevec_multiControlledPhaseShift()</a>, <a class="el" href="QuEST__common_8c_source.html#l00411">statevec_multiRotatePauli()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00423">validateMultiControlsMultiTargets()</a>.</p>

</div>
</div>
<a id="a2b323b65cd6512720e6aa27c182fcea0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2b323b65cd6512720e6aa27c182fcea0">&#9670;&nbsp;</a></span>getQuESTDefaultSeedKey()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void getQuESTDefaultSeedKey </td>
          <td>(</td>
          <td class="paramtype">unsigned long int *&#160;</td>
          <td class="paramname"><em>key</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00182">182</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;                                                   {</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    <span class="comment">// init MT random number generator with two keys -- time and pid</span></div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    <span class="comment">// for the MPI version, it is ok that all procs will get the same seed as random numbers will only be </span></div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    <span class="comment">// used by the master process</span></div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;<span class="preprocessor">#if defined(_WIN32) &amp;&amp; ! defined(__MINGW32__)</span></div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;  </div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> pid = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> int) _getpid();</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> msecs = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> int) GetTickCount64();</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160; </div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    key[0] = msecs; key[1] = pid;</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    <span class="keyword">struct </span>timeval  tv;</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    gettimeofday(&amp;tv, NULL);</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160; </div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    <span class="keywordtype">double</span> time_in_mill =</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;        (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000 ; <span class="comment">// convert tv_sec &amp; tv_usec to millisecond</span></div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160; </div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> pid = getpid();</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> msecs = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> int) time_in_mill;</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160; </div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    key[0] = msecs; key[1] = pid;</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;<span class="preprocessor">#endif </span></div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01318">seedQuESTDefault()</a>.</p>

</div>
</div>
<a id="a3cf54148e2162b04aeb634badb90826c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3cf54148e2162b04aeb634badb90826c">&#9670;&nbsp;</a></span>getVectorMagnitude()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> getVectorMagnitude </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a>&#160;</td>
          <td class="paramname"><em>vec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00073">73</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;                                     {</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="keywordflow">return</span> sqrt(vec.<a class="code" href="structVector.html#a0d0459a5b731ac5fb3dff2c6134e6e88">x</a>*vec.<a class="code" href="structVector.html#a0d0459a5b731ac5fb3dff2c6134e6e88">x</a> + vec.<a class="code" href="structVector.html#abc3cfc6c8e297b1153a373d84b981e6b">y</a>*vec.<a class="code" href="structVector.html#abc3cfc6c8e297b1153a373d84b981e6b">y</a> + vec.<a class="code" href="structVector.html#ab33976d8fda2e44b770f71269d698a25">z</a>*vec.<a class="code" href="structVector.html#ab33976d8fda2e44b770f71269d698a25">z</a>);</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00150">Vector::x</a>, <a class="el" href="QuEST_8h_source.html#l00150">Vector::y</a>, and <a class="el" href="QuEST_8h_source.html#l00150">Vector::z</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__common_8c_source.html#l00078">getUnitVector()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00475">validateVector()</a>.</p>

</div>
</div>
<a id="a404d177b894ce008289e44a599ad77d6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a404d177b894ce008289e44a599ad77d6">&#9670;&nbsp;</a></span>getZYZRotAnglesFromComplexPair()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void getZYZRotAnglesFromComplexPair </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>rz2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>ry</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>rz1</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>maps U(alpha, beta) to Rz(rz2) Ry(ry) Rz(rz1) </p>

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00124">124</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;                                                                                                    {</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    </div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> alphaMag = sqrt(alpha.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>*alpha.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> + alpha.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>*alpha.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>);</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    *ry = 2.0 * acos(alphaMag);</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    </div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> alphaPhase = atan2(alpha.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>, alpha.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>);</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> betaPhase  = atan2(beta.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>,  beta.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    *rz2 = - alphaPhase + betaPhase;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    *rz1 = - alphaPhase - betaPhase;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__qasm_8c_source.html#l00223">qasm_recordAxisRotation()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00195">qasm_recordCompactUnitary()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00300">qasm_recordControlledAxisRotation()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00264">qasm_recordControlledCompactUnitary()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00278">qasm_recordControlledUnitary()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00341">qasm_recordMultiControlledUnitary()</a>, and <a class="el" href="QuEST__qasm_8c_source.html#l00207">qasm_recordUnitary()</a>.</p>

</div>
</div>
<a id="ab76254cfde16f0808476649507a1a2fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab76254cfde16f0808476649507a1a2fc">&#9670;&nbsp;</a></span>hashString()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long int hashString </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>str</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00172">172</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;                                       {</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> hash = 5381;</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    <span class="keywordtype">int</span> c;</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160; </div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    <span class="keywordflow">while</span> ((c = *str++))</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;        hash = ((hash &lt;&lt; 5) + hash) + c; <span class="comment">/* hash * 33 + c */</span></div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160; </div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    <span class="keywordflow">return</span> hash;    </div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a9fd917537204e074119d4f283dea78e3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9fd917537204e074119d4f283dea78e3">&#9670;&nbsp;</a></span>setConjugateMatrixN()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void setConjugateMatrixN </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>m</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00109">109</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;                                           {</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    <span class="keywordtype">int</span> len = 1 &lt;&lt; m.<a class="code" href="structComplexMatrixN.html#a606f7afbc3f65a596bdca21cb43be6a8">numQubits</a>;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    <a class="code" href="QuEST__common_8c.html#ae2b222fda52c10fb420cb3ac78ca31e4">macro_setConjugateMatrix</a>(m, m, len);</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00093">macro_setConjugateMatrix</a>, and <a class="el" href="QuEST_8h_source.html#l00138">ComplexMatrixN::numQubits</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00314">controlledMultiQubitUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00331">multiControlledMultiQubitUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00297">multiQubitUnitary()</a>.</p>

</div>
</div>
<a id="acf1c651a4359a370a2d9b3e1e1ebd430"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acf1c651a4359a370a2d9b3e1e1ebd430">&#9670;&nbsp;</a></span>shiftIndices()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void shiftIndices </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>indices</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numIndices</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>shift</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00150">150</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;                                                           {</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0; j &lt; numIndices; j++)</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;        indices[j] += shift;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00314">controlledMultiQubitUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00331">multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST_8c_source.html#l00561">multiControlledPhaseFlip()</a>, <a class="el" href="QuEST_8c_source.html#l00511">multiControlledPhaseShift()</a>, <a class="el" href="QuEST_8c_source.html#l00297">multiQubitUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00642">multiRotatePauli()</a>.</p>

</div>
</div>
<a id="a27294e3065ebe42a65b3b9e0f85551dd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a27294e3065ebe42a65b3b9e0f85551dd">&#9670;&nbsp;</a></span>statevec_applyDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_applyDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03661">3661</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03661"></a><span class="lineno"> 3661</span>&#160;                                                          {</div>
<div class="line"><a name="l03662"></a><span class="lineno"> 3662</span>&#160; </div>
<div class="line"><a name="l03663"></a><span class="lineno"> 3663</span>&#160;    <span class="comment">// each node/chunk modifies only its values in an embarrassingly parallelisable way</span></div>
<div class="line"><a name="l03664"></a><span class="lineno"> 3664</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03665"></a><span class="lineno"> 3665</span>&#160; </div>
<div class="line"><a name="l03666"></a><span class="lineno"> 3666</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* stateRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03667"></a><span class="lineno"> 3667</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* stateIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03668"></a><span class="lineno"> 3668</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* opRe = op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>;</div>
<div class="line"><a name="l03669"></a><span class="lineno"> 3669</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* opIm = op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>;</div>
<div class="line"><a name="l03670"></a><span class="lineno"> 3670</span>&#160; </div>
<div class="line"><a name="l03671"></a><span class="lineno"> 3671</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> a,b,c,d;</div>
<div class="line"><a name="l03672"></a><span class="lineno"> 3672</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03673"></a><span class="lineno"> 3673</span>&#160; </div>
<div class="line"><a name="l03674"></a><span class="lineno"> 3674</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03675"></a><span class="lineno"> 3675</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03676"></a><span class="lineno"> 3676</span>&#160;<span class="preprocessor">    shared    (stateRe,stateIm, opRe,opIm, numAmps) \</span></div>
<div class="line"><a name="l03677"></a><span class="lineno"> 3677</span>&#160;<span class="preprocessor">    private   (index, a,b,c,d)</span></div>
<div class="line"><a name="l03678"></a><span class="lineno"> 3678</span>&#160;<span class="preprocessor"># endif </span></div>
<div class="line"><a name="l03679"></a><span class="lineno"> 3679</span>&#160;    {</div>
<div class="line"><a name="l03680"></a><span class="lineno"> 3680</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03681"></a><span class="lineno"> 3681</span>&#160;<span class="preprocessor"># pragma omp for schedule  (static)</span></div>
<div class="line"><a name="l03682"></a><span class="lineno"> 3682</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03683"></a><span class="lineno"> 3683</span>&#160;        <span class="keywordflow">for</span> (index=0LL; index&lt;numAmps; index++) {</div>
<div class="line"><a name="l03684"></a><span class="lineno"> 3684</span>&#160;            a = stateRe[index];</div>
<div class="line"><a name="l03685"></a><span class="lineno"> 3685</span>&#160;            b = stateIm[index];</div>
<div class="line"><a name="l03686"></a><span class="lineno"> 3686</span>&#160;            c = opRe[index];</div>
<div class="line"><a name="l03687"></a><span class="lineno"> 3687</span>&#160;            d = opIm[index];</div>
<div class="line"><a name="l03688"></a><span class="lineno"> 3688</span>&#160; </div>
<div class="line"><a name="l03689"></a><span class="lineno"> 3689</span>&#160;            <span class="comment">// (a + b i)(c + d i) = (a c - b d) + i (a d + b c)</span></div>
<div class="line"><a name="l03690"></a><span class="lineno"> 3690</span>&#160;            stateRe[index] = a*c - b*d;</div>
<div class="line"><a name="l03691"></a><span class="lineno"> 3691</span>&#160;            stateIm[index] = a*d + b*c;</div>
<div class="line"><a name="l03692"></a><span class="lineno"> 3692</span>&#160;        }</div>
<div class="line"><a name="l03693"></a><span class="lineno"> 3693</span>&#160;    }</div>
<div class="line"><a name="l03694"></a><span class="lineno"> 3694</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00887">applyDiagonalOp()</a>.</p>

</div>
</div>
<a id="af71c2470694795a8d639be8ff9c34ed5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af71c2470694795a8d639be8ff9c34ed5">&#9670;&nbsp;</a></span>statevec_applyPauliSum()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_applyPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>inQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>allCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>termCoeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSumTerms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>outQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00494">494</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;                                                                                                                           {</div>
<div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160;    </div>
<div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;    <span class="keywordtype">int</span> numQb = inQureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;    <span class="keywordtype">int</span> targs[numQb];</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> q=0; q &lt; numQb; q++)</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;        targs[q] = q;</div>
<div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;        </div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a758bad4237ff0bf3b4ff5be626a982ae">statevec_initBlankState</a>(outQureg);</div>
<div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;    </div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t &lt; numSumTerms; t++) {</div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;        <a class="code" href="structComplex.html">Complex</a> coef = (<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=termCoeffs[t], .imag=0};</div>
<div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;        <a class="code" href="structComplex.html">Complex</a> iden = (<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=1, .imag=0};</div>
<div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;        <a class="code" href="structComplex.html">Complex</a> zero = (<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=0, .imag=0};</div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;        </div>
<div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;        <span class="comment">// outQureg += coef paulis(inQureg)</span></div>
<div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;        <a class="code" href="QuEST__common_8c.html#accae504dfcd6846159baa16a1e8263a0">statevec_applyPauliProd</a>(inQureg, targs, &amp;allCodes[t*numQb], numQb);</div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;        <a class="code" href="QuEST__internal_8h.html#ad64a23933361fafc1b6b1787759c2663">statevec_setWeightedQureg</a>(coef, inQureg, iden, outQureg, zero, outQureg); </div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;        </div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;        <span class="comment">// undero paulis(inQureg), exploiting XX=YY=ZZ=I</span></div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;        <a class="code" href="QuEST__common_8c.html#accae504dfcd6846159baa16a1e8263a0">statevec_applyPauliProd</a>(inQureg, targs, &amp;allCodes[t*numQb], numQb);</div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;    }</div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__common_8c_source.html#l00451">statevec_applyPauliProd()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01398">statevec_initBlankState()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03619">statevec_setWeightedQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00819">applyPauliHamil()</a>, and <a class="el" href="QuEST_8c_source.html#l00808">applyPauliSum()</a>.</p>

</div>
</div>
<a id="a0fb948ddab4ca210e523aa3c52639df4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0fb948ddab4ca210e523aa3c52639df4">&#9670;&nbsp;</a></span>statevec_calcExpecDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> statevec_calcExpecDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01523">1523</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01523"></a><span class="lineno"> 1523</span>&#160;                                                                 {</div>
<div class="line"><a name="l01524"></a><span class="lineno"> 1524</span>&#160; </div>
<div class="line"><a name="l01525"></a><span class="lineno"> 1525</span>&#160;    <a class="code" href="structComplex.html">Complex</a> localExpec = <a class="code" href="QuEST__cpu_8c.html#a16ccb485bcffb328bbd5b2af6977cead">statevec_calcExpecDiagonalOpLocal</a>(qureg, op);</div>
<div class="line"><a name="l01526"></a><span class="lineno"> 1526</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> == 1)</div>
<div class="line"><a name="l01527"></a><span class="lineno"> 1527</span>&#160;        <span class="keywordflow">return</span> localExpec;</div>
<div class="line"><a name="l01528"></a><span class="lineno"> 1528</span>&#160;        </div>
<div class="line"><a name="l01529"></a><span class="lineno"> 1529</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localReal = localExpec.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l01530"></a><span class="lineno"> 1530</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localImag = localExpec.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l01531"></a><span class="lineno"> 1531</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalReal, globalImag;</div>
<div class="line"><a name="l01532"></a><span class="lineno"> 1532</span>&#160;    MPI_Allreduce(&amp;localReal, &amp;globalReal, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01533"></a><span class="lineno"> 1533</span>&#160;    MPI_Allreduce(&amp;localImag, &amp;globalImag, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01534"></a><span class="lineno"> 1534</span>&#160;    </div>
<div class="line"><a name="l01535"></a><span class="lineno"> 1535</span>&#160;    <a class="code" href="structComplex.html">Complex</a> globalExpec;</div>
<div class="line"><a name="l01536"></a><span class="lineno"> 1536</span>&#160;    globalExpec.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = globalReal;</div>
<div class="line"><a name="l01537"></a><span class="lineno"> 1537</span>&#160;    globalExpec.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = globalImag;</div>
<div class="line"><a name="l01538"></a><span class="lineno"> 1538</span>&#160;    <span class="keywordflow">return</span> globalExpec;</div>
<div class="line"><a name="l01539"></a><span class="lineno"> 1539</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST_8h_source.html#l00193">DiagonalOp::deviceOperator</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03738">statevec_calcExpecDiagonalOpLocal()</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00979">calcExpecDiagonalOp()</a>.</p>

</div>
</div>
<a id="aef380928d1b0003411d6159ca6594cd5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aef380928d1b0003411d6159ca6594cd5">&#9670;&nbsp;</a></span>statevec_calcExpecPauliProd()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcExpecPauliProd </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targetQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>pauliCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>workspace</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00465">465</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;                                                                                                                                 {</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;    </div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;    <a class="code" href="QuEST__internal_8h.html#aa4b77089145184d990848cd66993aa8b">statevec_cloneQureg</a>(workspace, qureg);</div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;    <a class="code" href="QuEST__common_8c.html#accae504dfcd6846159baa16a1e8263a0">statevec_applyPauliProd</a>(workspace, targetQubits, pauliCodes, numTargets);</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;    </div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;    <span class="comment">// compute the expected value</span></div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> value;</div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;        value = <a class="code" href="QuEST__internal_8h.html#a6153547f245c05874161a105e9a2f02c">densmatr_calcTotalProb</a>(workspace); <span class="comment">// Trace(ops qureg)</span></div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;        value = <a class="code" href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a>(workspace, qureg).<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>; <span class="comment">// &lt;qureg|ops|qureg&gt;</span></div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;                </div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;    <span class="keywordflow">return</span> value;</div>
<div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00053">densmatr_calcTotalProb()</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__common_8c_source.html#l00451">statevec_applyPauliProd()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00035">statevec_calcInnerProduct()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01506">statevec_cloneQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00952">calcExpecPauliProd()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00480">statevec_calcExpecPauliSum()</a>.</p>

</div>
</div>
<a id="ae0cfea24091c8336146aa84c2253992e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae0cfea24091c8336146aa84c2253992e">&#9670;&nbsp;</a></span>statevec_calcExpecPauliSum()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcExpecPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>allCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>termCoeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSumTerms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>workspace</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00480">480</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;                                                                                                                               {</div>
<div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;    </div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;    <span class="keywordtype">int</span> numQb = qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;    <span class="keywordtype">int</span> targs[numQb];</div>
<div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> q=0; q &lt; numQb; q++)</div>
<div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;        targs[q] = q;</div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;        </div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> value = 0;</div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t &lt; numSumTerms; t++)</div>
<div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160;        value += termCoeffs[t] * <a class="code" href="QuEST__common_8c.html#aef380928d1b0003411d6159ca6594cd5">statevec_calcExpecPauliProd</a>(qureg, targs, &amp;allCodes[t*numQb], numQb, workspace);</div>
<div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;        </div>
<div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;    <span class="keywordflow">return</span> value;</div>
<div class="line"><a name="l00492"></a><span class="lineno">  492</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST__common_8c_source.html#l00465">statevec_calcExpecPauliProd()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00970">calcExpecPauliHamil()</a>, and <a class="el" href="QuEST_8c_source.html#l00961">calcExpecPauliSum()</a>.</p>

</div>
</div>
<a id="aeeec9fe1501e25930adf6c38763a158e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeeec9fe1501e25930adf6c38763a158e">&#9670;&nbsp;</a></span>statevec_calcFidelity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcFidelity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>pureState</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00377">377</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;                                                          {</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;    </div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;    <a class="code" href="structComplex.html">Complex</a> innerProd = <a class="code" href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a>(qureg, pureState);</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> innerProdMag = innerProd.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>*innerProd.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> + innerProd.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>*innerProd.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;    <span class="keywordflow">return</span> innerProdMag;</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00035">statevec_calcInnerProduct()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00942">calcFidelity()</a>.</p>

</div>
</div>
<a id="a7ebd3198a198f4cd20840f64fd8b84d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7ebd3198a198f4cd20840f64fd8b84d0">&#9670;&nbsp;</a></span>statevec_calcInnerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> statevec_calcInnerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>bra</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>ket</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Terrible code which unnecessarily individually computes and sums the real and imaginary components of the inner product, so as to not have to worry about keeping the sums separated during reduction. </p>
<p>Truly disgusting, probably doubles runtime, please fix. @TODO could even do the kernel twice, storing real in bra.reduc and imag in ket.reduc? </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00035">35</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;                                                        {</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    </div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <a class="code" href="structComplex.html">Complex</a> localInnerProd = <a class="code" href="QuEST__cpu_8c.html#a6fbb3b693f25dde1e9e3dc87dc1984f7">statevec_calcInnerProductLocal</a>(bra, ket);</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    <span class="keywordflow">if</span> (bra.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> == 1)</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        <span class="keywordflow">return</span> localInnerProd;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    </div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localReal = localInnerProd.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localImag = localInnerProd.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalReal, globalImag;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    MPI_Allreduce(&amp;localReal, &amp;globalReal, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    MPI_Allreduce(&amp;localImag, &amp;globalImag, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    </div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <a class="code" href="structComplex.html">Complex</a> globalInnerProd;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    globalInnerProd.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = globalReal;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    globalInnerProd.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = globalImag;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keywordflow">return</span> globalInnerProd;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l01806">copySharedReduceBlock()</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01071">statevec_calcInnerProductLocal()</a>, and <a class="el" href="QuEST__gpu_8cu_source.html#l01912">swapDouble()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00910">calcInnerProduct()</a>, <a class="el" href="QuEST__common_8c_source.html#l00465">statevec_calcExpecPauliProd()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00377">statevec_calcFidelity()</a>.</p>

</div>
</div>
<a id="a63cb88a5f4eb12fef087435b8db3f8eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a63cb88a5f4eb12fef087435b8db3f8eb">&#9670;&nbsp;</a></span>statevec_calcProbOfOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcProbOfOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01260">1260</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01261"></a><span class="lineno"> 1261</span>&#160;{</div>
<div class="line"><a name="l01262"></a><span class="lineno"> 1262</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> stateProb=0, totalStateProb=0;</div>
<div class="line"><a name="l01263"></a><span class="lineno"> 1263</span>&#160;    <span class="keywordtype">int</span> skipValuesWithinRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit);</div>
<div class="line"><a name="l01264"></a><span class="lineno"> 1264</span>&#160;    <span class="keywordflow">if</span> (skipValuesWithinRank) {</div>
<div class="line"><a name="l01265"></a><span class="lineno"> 1265</span>&#160;        stateProb = <a class="code" href="QuEST__cpu_8c.html#a8535bc15c2ff249ddddb3fde6eff1490">statevec_findProbabilityOfZeroLocal</a>(qureg, measureQubit);</div>
<div class="line"><a name="l01266"></a><span class="lineno"> 1266</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01267"></a><span class="lineno"> 1267</span>&#160;        <span class="keywordflow">if</span> (!<a class="code" href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit)){</div>
<div class="line"><a name="l01268"></a><span class="lineno"> 1268</span>&#160;            stateProb = <a class="code" href="QuEST__cpu_8c.html#a430d98e35f1eae7f0815ac539057cf67">statevec_findProbabilityOfZeroDistributed</a>(qureg);</div>
<div class="line"><a name="l01269"></a><span class="lineno"> 1269</span>&#160;        } <span class="keywordflow">else</span> stateProb = 0;</div>
<div class="line"><a name="l01270"></a><span class="lineno"> 1270</span>&#160;    }</div>
<div class="line"><a name="l01271"></a><span class="lineno"> 1271</span>&#160;    MPI_Allreduce(&amp;stateProb, &amp;totalStateProb, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01272"></a><span class="lineno"> 1272</span>&#160;    <span class="keywordflow">if</span> (outcome==1) totalStateProb = 1.0 - totalStateProb;</div>
<div class="line"><a name="l01273"></a><span class="lineno"> 1273</span>&#160;    <span class="keywordflow">return</span> totalStateProb;</div>
<div class="line"><a name="l01274"></a><span class="lineno"> 1274</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01251">isChunkToSkipInFindPZero()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01967">statevec_findProbabilityOfZero()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03262">statevec_findProbabilityOfZeroDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03206">statevec_findProbabilityOfZeroLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00926">calcProbOfOutcome()</a>, <a class="el" href="QuEST_8c_source.html#l00726">collapseToOutcome()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00361">statevec_measureWithStats()</a>.</p>

</div>
</div>
<a id="ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad65ad1b5ea6f30b0c6b4ffda96e1a8e6">&#9670;&nbsp;</a></span>statevec_calcTotalProb()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcTotalProb </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00088">88</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;                                         {</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="comment">// Implemented using Kahan summation for greater accuracy at a slight floating</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="comment">//   point operation overhead. For more details see https://en.wikipedia.org/wiki/Kahan_summation_algorithm</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> pTotal=0; </div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> y, t, c;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> allRankTotals=0;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmpsPerRank = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    c = 0.0;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    <span class="keywordflow">for</span> (index=0; index&lt;numAmpsPerRank; index++){ </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="comment">// Perform pTotal+=qureg.stateVec.real[index]*qureg.stateVec.real[index]; by Kahan</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        y = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index]*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index] - c;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        t = pTotal + y;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <span class="comment">// Don&#39;t change the bracketing on the following line</span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        c = ( t - pTotal ) - y;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        pTotal = t;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        <span class="comment">// Perform pTotal+=qureg.stateVec.imag[index]*qureg.stateVec.imag[index]; by Kahan</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;        y = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index] - c;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        t = pTotal + y;</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        <span class="comment">// Don&#39;t change the bracketing on the following line</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        c = ( t - pTotal ) - y;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        pTotal = t;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    } </div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>&gt;1)</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;                MPI_Allreduce(&amp;pTotal, &amp;allRankTotals, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">else</span> </div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;                allRankTotals=pTotal;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160; </div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    <span class="keywordflow">return</span> allRankTotals;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00461">copyStateFromGPU()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00903">calcTotalProb()</a>.</p>

</div>
</div>
<a id="aa4b77089145184d990848cd66993aa8b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa4b77089145184d990848cd66993aa8b">&#9670;&nbsp;</a></span>statevec_cloneQureg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_cloneQureg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>targetQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>copyQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>works for both statevectors and density matrices </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01506">1506</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01506"></a><span class="lineno"> 1506</span>&#160;                                                             {</div>
<div class="line"><a name="l01507"></a><span class="lineno"> 1507</span>&#160;    </div>
<div class="line"><a name="l01508"></a><span class="lineno"> 1508</span>&#160;    <span class="comment">// registers are equal sized, so nodes hold the same state-vector partitions</span></div>
<div class="line"><a name="l01509"></a><span class="lineno"> 1509</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l01510"></a><span class="lineno"> 1510</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01511"></a><span class="lineno"> 1511</span>&#160; </div>
<div class="line"><a name="l01512"></a><span class="lineno"> 1512</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01513"></a><span class="lineno"> 1513</span>&#160;    stateVecSize = targetQureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01514"></a><span class="lineno"> 1514</span>&#160; </div>
<div class="line"><a name="l01515"></a><span class="lineno"> 1515</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01516"></a><span class="lineno"> 1516</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *targetStateVecReal = targetQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01517"></a><span class="lineno"> 1517</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *targetStateVecImag = targetQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01518"></a><span class="lineno"> 1518</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *copyStateVecReal = copyQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01519"></a><span class="lineno"> 1519</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *copyStateVecImag = copyQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01520"></a><span class="lineno"> 1520</span>&#160; </div>
<div class="line"><a name="l01521"></a><span class="lineno"> 1521</span>&#160;    <span class="comment">// initialise the state to |0000..0000&gt;</span></div>
<div class="line"><a name="l01522"></a><span class="lineno"> 1522</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01523"></a><span class="lineno"> 1523</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01524"></a><span class="lineno"> 1524</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01525"></a><span class="lineno"> 1525</span>&#160;<span class="preprocessor">    shared   (stateVecSize, targetStateVecReal, targetStateVecImag, copyStateVecReal, copyStateVecImag) \</span></div>
<div class="line"><a name="l01526"></a><span class="lineno"> 1526</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01527"></a><span class="lineno"> 1527</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01528"></a><span class="lineno"> 1528</span>&#160;    {</div>
<div class="line"><a name="l01529"></a><span class="lineno"> 1529</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01530"></a><span class="lineno"> 1530</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01531"></a><span class="lineno"> 1531</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01532"></a><span class="lineno"> 1532</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l01533"></a><span class="lineno"> 1533</span>&#160;            targetStateVecReal[index] = copyStateVecReal[index];</div>
<div class="line"><a name="l01534"></a><span class="lineno"> 1534</span>&#160;            targetStateVecImag[index] = copyStateVecImag[index];</div>
<div class="line"><a name="l01535"></a><span class="lineno"> 1535</span>&#160;        }</div>
<div class="line"><a name="l01536"></a><span class="lineno"> 1536</span>&#160;    }</div>
<div class="line"><a name="l01537"></a><span class="lineno"> 1537</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00165">cloneQureg()</a>, <a class="el" href="QuEST_8c_source.html#l00064">createCloneQureg()</a>, <a class="el" href="QuEST_8c_source.html#l00145">initPureState()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00465">statevec_calcExpecPauliProd()</a>.</p>

</div>
</div>
<a id="a008becc4a18f868340836e0ab9fd6df6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a008becc4a18f868340836e0ab9fd6df6">&#9670;&nbsp;</a></span>statevec_collapseToKnownProbOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_collapseToKnownProbOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>outcomeProb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01298">1298</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01299"></a><span class="lineno"> 1299</span>&#160;{</div>
<div class="line"><a name="l01300"></a><span class="lineno"> 1300</span>&#160;    <span class="keywordtype">int</span> skipValuesWithinRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit);</div>
<div class="line"><a name="l01301"></a><span class="lineno"> 1301</span>&#160;    <span class="keywordflow">if</span> (skipValuesWithinRank) {</div>
<div class="line"><a name="l01302"></a><span class="lineno"> 1302</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab02bce0ebbb8f624e8ced8b09b99cdef">statevec_collapseToKnownProbOutcomeLocal</a>(qureg, measureQubit, outcome, totalStateProb);</div>
<div class="line"><a name="l01303"></a><span class="lineno"> 1303</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01304"></a><span class="lineno"> 1304</span>&#160;        <span class="keywordflow">if</span> (!<a class="code" href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit)){</div>
<div class="line"><a name="l01305"></a><span class="lineno"> 1305</span>&#160;            <span class="comment">// chunk has amps for q=0</span></div>
<div class="line"><a name="l01306"></a><span class="lineno"> 1306</span>&#160;            <span class="keywordflow">if</span> (outcome==0) <a class="code" href="QuEST__cpu_8c.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a>(qureg, measureQubit, </div>
<div class="line"><a name="l01307"></a><span class="lineno"> 1307</span>&#160;                    totalStateProb);</div>
<div class="line"><a name="l01308"></a><span class="lineno"> 1308</span>&#160;            <span class="keywordflow">else</span> <a class="code" href="QuEST__cpu_8c.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a>(qureg);</div>
<div class="line"><a name="l01309"></a><span class="lineno"> 1309</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01310"></a><span class="lineno"> 1310</span>&#160;            <span class="comment">// chunk has amps for q=1</span></div>
<div class="line"><a name="l01311"></a><span class="lineno"> 1311</span>&#160;            <span class="keywordflow">if</span> (outcome==1) <a class="code" href="QuEST__cpu_8c.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a>(qureg, measureQubit, </div>
<div class="line"><a name="l01312"></a><span class="lineno"> 1312</span>&#160;                    totalStateProb);</div>
<div class="line"><a name="l01313"></a><span class="lineno"> 1313</span>&#160;            <span class="keywordflow">else</span> <a class="code" href="QuEST__cpu_8c.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a>(qureg);</div>
<div class="line"><a name="l01314"></a><span class="lineno"> 1314</span>&#160;        }</div>
<div class="line"><a name="l01315"></a><span class="lineno"> 1315</span>&#160;    }</div>
<div class="line"><a name="l01316"></a><span class="lineno"> 1316</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01251">isChunkToSkipInFindPZero()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03462">statevec_collapseToKnownProbOutcomeDistributedRenorm()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03380">statevec_collapseToKnownProbOutcomeLocal()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03501">statevec_collapseToOutcomeDistributedSetZero()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00726">collapseToOutcome()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00361">statevec_measureWithStats()</a>.</p>

</div>
</div>
<a id="aec63559e8b9ab0e17efe18d64d2ceca6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aec63559e8b9ab0e17efe18d64d2ceca6">&#9670;&nbsp;</a></span>statevec_compactUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_compactUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">844</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00845"></a><span class="lineno">  845</span>&#160;{</div>
<div class="line"><a name="l00846"></a><span class="lineno">  846</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00847"></a><span class="lineno">  847</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00848"></a><span class="lineno">  848</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00849"></a><span class="lineno">  849</span>&#160; </div>
<div class="line"><a name="l00850"></a><span class="lineno">  850</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00851"></a><span class="lineno">  851</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00852"></a><span class="lineno">  852</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00853"></a><span class="lineno">  853</span>&#160; </div>
<div class="line"><a name="l00854"></a><span class="lineno">  854</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00855"></a><span class="lineno">  855</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00856"></a><span class="lineno">  856</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a5ddfdb22e4704b680d67d08d9e80835b">statevec_compactUnitaryLocal</a>(qureg, targetQubit, alpha, beta);</div>
<div class="line"><a name="l00857"></a><span class="lineno">  857</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00858"></a><span class="lineno">  858</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00859"></a><span class="lineno">  859</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00860"></a><span class="lineno">  860</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a>(rankIsUpper, &amp;rot1, &amp;rot2, alpha, beta);</div>
<div class="line"><a name="l00861"></a><span class="lineno">  861</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00862"></a><span class="lineno">  862</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00863"></a><span class="lineno">  863</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00864"></a><span class="lineno">  864</span>&#160; </div>
<div class="line"><a name="l00865"></a><span class="lineno">  865</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. </span></div>
<div class="line"><a name="l00866"></a><span class="lineno">  866</span>&#160;        <span class="comment">// send values to compactUnitaryDistributed in the correct order</span></div>
<div class="line"><a name="l00867"></a><span class="lineno">  867</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00868"></a><span class="lineno">  868</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00869"></a><span class="lineno">  869</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00870"></a><span class="lineno">  870</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00871"></a><span class="lineno">  871</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00872"></a><span class="lineno">  872</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00873"></a><span class="lineno">  873</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00874"></a><span class="lineno">  874</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00875"></a><span class="lineno">  875</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00876"></a><span class="lineno">  876</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00877"></a><span class="lineno">  877</span>&#160;        }</div>
<div class="line"><a name="l00878"></a><span class="lineno">  878</span>&#160;    }</div>
<div class="line"><a name="l00879"></a><span class="lineno">  879</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00258">getRotAngle()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02001">statevec_compactUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01688">statevec_compactUnitaryLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00405">compactUnitary()</a>, <a class="el" href="QuEST__common_8c_source.html#l00411">statevec_multiRotatePauli()</a>, <a class="el" href="QuEST__common_8c_source.html#l00311">statevec_rotateAroundAxis()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00318">statevec_rotateAroundAxisConj()</a>.</p>

</div>
</div>
<a id="ae6cecbad32a03416138b321cdc1a2c33"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae6cecbad32a03416138b321cdc1a2c33">&#9670;&nbsp;</a></span>statevec_compareStates()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int statevec_compareStates </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>mq1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>mq2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>precision</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01675">1675</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01675"></a><span class="lineno"> 1675</span>&#160;                                                                 {</div>
<div class="line"><a name="l01676"></a><span class="lineno"> 1676</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> diff;</div>
<div class="line"><a name="l01677"></a><span class="lineno"> 1677</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize = mq1.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01678"></a><span class="lineno"> 1678</span>&#160;    </div>
<div class="line"><a name="l01679"></a><span class="lineno"> 1679</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> i=0; i&lt;chunkSize; i++){</div>
<div class="line"><a name="l01680"></a><span class="lineno"> 1680</span>&#160;        diff = absReal(mq1.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i] - mq2.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i]);</div>
<div class="line"><a name="l01681"></a><span class="lineno"> 1681</span>&#160;        <span class="keywordflow">if</span> (diff&gt;precision) <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l01682"></a><span class="lineno"> 1682</span>&#160;        diff = absReal(mq1.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i] - mq2.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i]);</div>
<div class="line"><a name="l01683"></a><span class="lineno"> 1683</span>&#160;        <span class="keywordflow">if</span> (diff&gt;precision) <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l01684"></a><span class="lineno"> 1684</span>&#160;    }</div>
<div class="line"><a name="l01685"></a><span class="lineno"> 1685</span>&#160;    <span class="keywordflow">return</span> 1;</div>
<div class="line"><a name="l01686"></a><span class="lineno"> 1686</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00461">copyStateFromGPU()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01303">compareStates()</a>.</p>

</div>
</div>
<a id="a1275d604674224d87a173fb5bac78835"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1275d604674224d87a173fb5bac78835">&#9670;&nbsp;</a></span>statevec_controlledCompactUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledCompactUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">920</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00921"></a><span class="lineno">  921</span>&#160;{</div>
<div class="line"><a name="l00922"></a><span class="lineno">  922</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00923"></a><span class="lineno">  923</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00924"></a><span class="lineno">  924</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00925"></a><span class="lineno">  925</span>&#160; </div>
<div class="line"><a name="l00926"></a><span class="lineno">  926</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00927"></a><span class="lineno">  927</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00928"></a><span class="lineno">  928</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00929"></a><span class="lineno">  929</span>&#160; </div>
<div class="line"><a name="l00930"></a><span class="lineno">  930</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00931"></a><span class="lineno">  931</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00932"></a><span class="lineno">  932</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a215e2d6f88dbecc0b408b3573b5e144f">statevec_controlledCompactUnitaryLocal</a>(qureg, controlQubit, targetQubit, alpha, beta);</div>
<div class="line"><a name="l00933"></a><span class="lineno">  933</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00934"></a><span class="lineno">  934</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00935"></a><span class="lineno">  935</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00936"></a><span class="lineno">  936</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a>(rankIsUpper, &amp;rot1, &amp;rot2, alpha, beta);</div>
<div class="line"><a name="l00937"></a><span class="lineno">  937</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00938"></a><span class="lineno">  938</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l00939"></a><span class="lineno">  939</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00940"></a><span class="lineno">  940</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00941"></a><span class="lineno">  941</span>&#160; </div>
<div class="line"><a name="l00942"></a><span class="lineno">  942</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to controlledCompactUnitaryDistributed</span></div>
<div class="line"><a name="l00943"></a><span class="lineno">  943</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l00944"></a><span class="lineno">  944</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00945"></a><span class="lineno">  945</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00946"></a><span class="lineno">  946</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00947"></a><span class="lineno">  947</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00948"></a><span class="lineno">  948</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00949"></a><span class="lineno">  949</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00950"></a><span class="lineno">  950</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00951"></a><span class="lineno">  951</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00952"></a><span class="lineno">  952</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00953"></a><span class="lineno">  953</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00954"></a><span class="lineno">  954</span>&#160;        }</div>
<div class="line"><a name="l00955"></a><span class="lineno">  955</span>&#160;    }</div>
<div class="line"><a name="l00956"></a><span class="lineno">  956</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00258">getRotAngle()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02319">statevec_controlledCompactUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02101">statevec_controlledCompactUnitaryLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00418">controlledCompactUnitary()</a>, <a class="el" href="QuEST__common_8c_source.html#l00327">statevec_controlledRotateAroundAxis()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00334">statevec_controlledRotateAroundAxisConj()</a>.</p>

</div>
</div>
<a id="a06b8474aec51579ff680fb66439e7fc6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a06b8474aec51579ff680fb66439e7fc6">&#9670;&nbsp;</a></span>statevec_controlledMultiQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledMultiQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00535">535</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00535"></a><span class="lineno">  535</span>&#160;                                                                                                                 {</div>
<div class="line"><a name="l00536"></a><span class="lineno">  536</span>&#160;    </div>
<div class="line"><a name="l00537"></a><span class="lineno">  537</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> ctrlMask = 1LL &lt;&lt; ctrl;</div>
<div class="line"><a name="l00538"></a><span class="lineno">  538</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a>(qureg, ctrlMask, targets, numTargets, u);</div>
<div class="line"><a name="l00539"></a><span class="lineno">  539</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">statevec_multiControlledMultiQubitUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00314">controlledMultiQubitUnitary()</a>.</p>

</div>
</div>
<a id="abb2eab4af99adcc59be24f4c91c6f6ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb2eab4af99adcc59be24f4c91c6f6ad">&#9670;&nbsp;</a></span>statevec_controlledNot()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledNot </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01061">1061</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>&#160;{</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>&#160; </div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01069"></a><span class="lineno"> 1069</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ace1482ef82b83e7f926634a67b322fc4">statevec_controlledNotLocal</a>(qureg, controlQubit, targetQubit);</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01080"></a><span class="lineno"> 1080</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//out</span></div>
<div class="line"><a name="l01082"></a><span class="lineno"> 1082</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01083"></a><span class="lineno"> 1083</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01084"></a><span class="lineno"> 1084</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//out</span></div>
<div class="line"><a name="l01086"></a><span class="lineno"> 1086</span>&#160;        }</div>
<div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>&#160;    }</div>
<div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02646">statevec_controlledNotDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02584">statevec_controlledNotLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00525">controlledNot()</a>.</p>

</div>
</div>
<a id="a4e19ef93d01d7acea32ca646d623aedd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4e19ef93d01d7acea32ca646d623aedd">&#9670;&nbsp;</a></span>statevec_controlledPauliY()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledPauliY </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01140">1140</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01141"></a><span class="lineno"> 1141</span>&#160;{</div>
<div class="line"><a name="l01142"></a><span class="lineno"> 1142</span>&#160;        <span class="keywordtype">int</span> conjFac = 1;</div>
<div class="line"><a name="l01143"></a><span class="lineno"> 1143</span>&#160; </div>
<div class="line"><a name="l01144"></a><span class="lineno"> 1144</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01145"></a><span class="lineno"> 1145</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01146"></a><span class="lineno"> 1146</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01147"></a><span class="lineno"> 1147</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01148"></a><span class="lineno"> 1148</span>&#160; </div>
<div class="line"><a name="l01149"></a><span class="lineno"> 1149</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01150"></a><span class="lineno"> 1150</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01151"></a><span class="lineno"> 1151</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a06fb16aa4af7c54d36052a14d3ad58a7">statevec_controlledPauliYLocal</a>(qureg, controlQubit, targetQubit, conjFac);</div>
<div class="line"><a name="l01152"></a><span class="lineno"> 1152</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01153"></a><span class="lineno"> 1153</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01154"></a><span class="lineno"> 1154</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01155"></a><span class="lineno"> 1155</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01156"></a><span class="lineno"> 1156</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01157"></a><span class="lineno"> 1157</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01158"></a><span class="lineno"> 1158</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01159"></a><span class="lineno"> 1159</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01160"></a><span class="lineno"> 1160</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01161"></a><span class="lineno"> 1161</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01162"></a><span class="lineno"> 1162</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01163"></a><span class="lineno"> 1163</span>&#160;                                        conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01164"></a><span class="lineno"> 1164</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01165"></a><span class="lineno"> 1165</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01166"></a><span class="lineno"> 1166</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01167"></a><span class="lineno"> 1167</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01168"></a><span class="lineno"> 1168</span>&#160;                                        -conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01169"></a><span class="lineno"> 1169</span>&#160;        }</div>
<div class="line"><a name="l01170"></a><span class="lineno"> 1170</span>&#160;    }</div>
<div class="line"><a name="l01171"></a><span class="lineno"> 1171</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02830">statevec_controlledPauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02776">statevec_controlledPauliYLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00537">controlledPauliY()</a>.</p>

</div>
</div>
<a id="a4a2fa262d3f0dba372797b9bd35d9fa5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4a2fa262d3f0dba372797b9bd35d9fa5">&#9670;&nbsp;</a></span>statevec_controlledPauliYConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledPauliYConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01173">1173</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01174"></a><span class="lineno"> 1174</span>&#160;{</div>
<div class="line"><a name="l01175"></a><span class="lineno"> 1175</span>&#160;        <span class="keywordtype">int</span> conjFac = -1;</div>
<div class="line"><a name="l01176"></a><span class="lineno"> 1176</span>&#160; </div>
<div class="line"><a name="l01177"></a><span class="lineno"> 1177</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01178"></a><span class="lineno"> 1178</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01179"></a><span class="lineno"> 1179</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01180"></a><span class="lineno"> 1180</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01181"></a><span class="lineno"> 1181</span>&#160; </div>
<div class="line"><a name="l01182"></a><span class="lineno"> 1182</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01183"></a><span class="lineno"> 1183</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01184"></a><span class="lineno"> 1184</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a06fb16aa4af7c54d36052a14d3ad58a7">statevec_controlledPauliYLocal</a>(qureg, controlQubit, targetQubit, conjFac);</div>
<div class="line"><a name="l01185"></a><span class="lineno"> 1185</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01186"></a><span class="lineno"> 1186</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01187"></a><span class="lineno"> 1187</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01188"></a><span class="lineno"> 1188</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01189"></a><span class="lineno"> 1189</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01190"></a><span class="lineno"> 1190</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01191"></a><span class="lineno"> 1191</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01192"></a><span class="lineno"> 1192</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01193"></a><span class="lineno"> 1193</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01194"></a><span class="lineno"> 1194</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01195"></a><span class="lineno"> 1195</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01196"></a><span class="lineno"> 1196</span>&#160;                                        conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01197"></a><span class="lineno"> 1197</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01198"></a><span class="lineno"> 1198</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01199"></a><span class="lineno"> 1199</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01200"></a><span class="lineno"> 1200</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01201"></a><span class="lineno"> 1201</span>&#160;                                        -conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01202"></a><span class="lineno"> 1202</span>&#160;        }</div>
<div class="line"><a name="l01203"></a><span class="lineno"> 1203</span>&#160;    }</div>
<div class="line"><a name="l01204"></a><span class="lineno"> 1204</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02830">statevec_controlledPauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02776">statevec_controlledPauliYLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00537">controlledPauliY()</a>.</p>

</div>
</div>
<a id="aaf78491e35d165edfd57387f9fffecbd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf78491e35d165edfd57387f9fffecbd">&#9670;&nbsp;</a></span>statevec_controlledPhaseFlip()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledPhaseFlip </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>idQubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>idQubit2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03300">3300</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03301"></a><span class="lineno"> 3301</span>&#160;{</div>
<div class="line"><a name="l03302"></a><span class="lineno"> 3302</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03303"></a><span class="lineno"> 3303</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l03304"></a><span class="lineno"> 3304</span>&#160;    <span class="keywordtype">int</span> bit1, bit2;</div>
<div class="line"><a name="l03305"></a><span class="lineno"> 3305</span>&#160; </div>
<div class="line"><a name="l03306"></a><span class="lineno"> 3306</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03307"></a><span class="lineno"> 3307</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l03308"></a><span class="lineno"> 3308</span>&#160;    </div>
<div class="line"><a name="l03309"></a><span class="lineno"> 3309</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l03310"></a><span class="lineno"> 3310</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03311"></a><span class="lineno"> 3311</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03312"></a><span class="lineno"> 3312</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03313"></a><span class="lineno"> 3313</span>&#160; </div>
<div class="line"><a name="l03314"></a><span class="lineno"> 3314</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03315"></a><span class="lineno"> 3315</span>&#160;<span class="preprocessor"># pragma omp parallel for \</span></div>
<div class="line"><a name="l03316"></a><span class="lineno"> 3316</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l03317"></a><span class="lineno"> 3317</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal,stateVecImag, chunkId,chunkSize,idQubit1,idQubit2 ) \</span></div>
<div class="line"><a name="l03318"></a><span class="lineno"> 3318</span>&#160;<span class="preprocessor">    private  (index,bit1,bit2) \</span></div>
<div class="line"><a name="l03319"></a><span class="lineno"> 3319</span>&#160;<span class="preprocessor">    schedule (static)</span></div>
<div class="line"><a name="l03320"></a><span class="lineno"> 3320</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03321"></a><span class="lineno"> 3321</span>&#160;    <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l03322"></a><span class="lineno"> 3322</span>&#160;        bit1 = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a> (idQubit1, index+chunkId*chunkSize);</div>
<div class="line"><a name="l03323"></a><span class="lineno"> 3323</span>&#160;        bit2 = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a> (idQubit2, index+chunkId*chunkSize);</div>
<div class="line"><a name="l03324"></a><span class="lineno"> 3324</span>&#160;        <span class="keywordflow">if</span> (bit1 &amp;&amp; bit2) {</div>
<div class="line"><a name="l03325"></a><span class="lineno"> 3325</span>&#160;            stateVecReal [index] = - stateVecReal [index];</div>
<div class="line"><a name="l03326"></a><span class="lineno"> 3326</span>&#160;            stateVecImag [index] = - stateVecImag [index];</div>
<div class="line"><a name="l03327"></a><span class="lineno"> 3327</span>&#160;        }</div>
<div class="line"><a name="l03328"></a><span class="lineno"> 3328</span>&#160;    }</div>
<div class="line"><a name="l03329"></a><span class="lineno"> 3329</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00549">controlledPhaseFlip()</a>.</p>

</div>
</div>
<a id="a63df1ec14ff7cc81c3f392ac10fcc744"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a63df1ec14ff7cc81c3f392ac10fcc744">&#9670;&nbsp;</a></span>statevec_controlledPhaseShift()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledPhaseShift </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>idQubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>idQubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03019">3019</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03020"></a><span class="lineno"> 3020</span>&#160;{</div>
<div class="line"><a name="l03021"></a><span class="lineno"> 3021</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03022"></a><span class="lineno"> 3022</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l03023"></a><span class="lineno"> 3023</span>&#160;    <span class="keywordtype">int</span> bit1, bit2;</div>
<div class="line"><a name="l03024"></a><span class="lineno"> 3024</span>&#160;    </div>
<div class="line"><a name="l03025"></a><span class="lineno"> 3025</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03026"></a><span class="lineno"> 3026</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l03027"></a><span class="lineno"> 3027</span>&#160; </div>
<div class="line"><a name="l03028"></a><span class="lineno"> 3028</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l03029"></a><span class="lineno"> 3029</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03030"></a><span class="lineno"> 3030</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03031"></a><span class="lineno"> 3031</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03032"></a><span class="lineno"> 3032</span>&#160;    </div>
<div class="line"><a name="l03033"></a><span class="lineno"> 3033</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> stateRealLo, stateImagLo;</div>
<div class="line"><a name="l03034"></a><span class="lineno"> 3034</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> cosAngle = cos(angle);</div>
<div class="line"><a name="l03035"></a><span class="lineno"> 3035</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> sinAngle = sin(angle);</div>
<div class="line"><a name="l03036"></a><span class="lineno"> 3036</span>&#160; </div>
<div class="line"><a name="l03037"></a><span class="lineno"> 3037</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03038"></a><span class="lineno"> 3038</span>&#160;<span class="preprocessor"># pragma omp parallel for \</span></div>
<div class="line"><a name="l03039"></a><span class="lineno"> 3039</span>&#160;<span class="preprocessor">    default  (none)              \</span></div>
<div class="line"><a name="l03040"></a><span class="lineno"> 3040</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal,stateVecImag, chunkId,chunkSize, \</span></div>
<div class="line"><a name="l03041"></a><span class="lineno"> 3041</span>&#160;<span class="preprocessor">                idQubit1,idQubit2,cosAngle,sinAngle ) \</span></div>
<div class="line"><a name="l03042"></a><span class="lineno"> 3042</span>&#160;<span class="preprocessor">    private  (index,bit1,bit2,stateRealLo,stateImagLo) \</span></div>
<div class="line"><a name="l03043"></a><span class="lineno"> 3043</span>&#160;<span class="preprocessor">    schedule (static)</span></div>
<div class="line"><a name="l03044"></a><span class="lineno"> 3044</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03045"></a><span class="lineno"> 3045</span>&#160;    <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l03046"></a><span class="lineno"> 3046</span>&#160;        bit1 = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a> (idQubit1, index+chunkId*chunkSize);</div>
<div class="line"><a name="l03047"></a><span class="lineno"> 3047</span>&#160;        bit2 = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a> (idQubit2, index+chunkId*chunkSize);</div>
<div class="line"><a name="l03048"></a><span class="lineno"> 3048</span>&#160;        <span class="keywordflow">if</span> (bit1 &amp;&amp; bit2) {</div>
<div class="line"><a name="l03049"></a><span class="lineno"> 3049</span>&#160;            </div>
<div class="line"><a name="l03050"></a><span class="lineno"> 3050</span>&#160;            stateRealLo = stateVecReal[index];</div>
<div class="line"><a name="l03051"></a><span class="lineno"> 3051</span>&#160;            stateImagLo = stateVecImag[index];</div>
<div class="line"><a name="l03052"></a><span class="lineno"> 3052</span>&#160;            </div>
<div class="line"><a name="l03053"></a><span class="lineno"> 3053</span>&#160;            stateVecReal[index] = cosAngle*stateRealLo - sinAngle*stateImagLo;</div>
<div class="line"><a name="l03054"></a><span class="lineno"> 3054</span>&#160;            stateVecImag[index] = sinAngle*stateRealLo + cosAngle*stateImagLo;  </div>
<div class="line"><a name="l03055"></a><span class="lineno"> 3055</span>&#160;        }</div>
<div class="line"><a name="l03056"></a><span class="lineno"> 3056</span>&#160;    }</div>
<div class="line"><a name="l03057"></a><span class="lineno"> 3057</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00499">controlledPhaseShift()</a>.</p>

</div>
</div>
<a id="a336c3286d2434fc892ebe20e9fa22a24"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a336c3286d2434fc892ebe20e9fa22a24">&#9670;&nbsp;</a></span>statevec_controlledRotateAroundAxis()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledRotateAroundAxis </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a>&#160;</td>
          <td class="paramname"><em>axis</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00327">327</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;                                                                                                                  {</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160; </div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;    <a class="code" href="structComplex.html">Complex</a> alpha, beta;</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;    <a class="code" href="QuEST__common_8c.html#a71b3ae4402c1c5039d3086ca0e47a522">getComplexPairFromRotation</a>(angle, axis, &amp;alpha, &amp;beta);</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a1275d604674224d87a173fb5bac78835">statevec_controlledCompactUnitary</a>(qureg, controlQubit, targetQubit, alpha, beta);</div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00114">getComplexPairFromRotation()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00588">controlledRotateAroundAxis()</a>, <a class="el" href="QuEST__common_8c_source.html#l00343">statevec_controlledRotateX()</a>, <a class="el" href="QuEST__common_8c_source.html#l00349">statevec_controlledRotateY()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00355">statevec_controlledRotateZ()</a>.</p>

</div>
</div>
<a id="a5ea2384a9b33c94eac891aacbfa5da6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5ea2384a9b33c94eac891aacbfa5da6a">&#9670;&nbsp;</a></span>statevec_controlledRotateAroundAxisConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledRotateAroundAxisConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a>&#160;</td>
          <td class="paramname"><em>axis</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00334">334</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;                                                                                                                      {</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160; </div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;    <a class="code" href="structComplex.html">Complex</a> alpha, beta;</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;    <a class="code" href="QuEST__common_8c.html#a71b3ae4402c1c5039d3086ca0e47a522">getComplexPairFromRotation</a>(angle, axis, &amp;alpha, &amp;beta);</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;    alpha.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> *= -1; </div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;    beta.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> *= -1;</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a1275d604674224d87a173fb5bac78835">statevec_controlledCompactUnitary</a>(qureg, controlQubit, targetQubit, alpha, beta);</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00114">getComplexPairFromRotation()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00588">controlledRotateAroundAxis()</a>.</p>

</div>
</div>
<a id="aa32eed5bc38e85193e1aa23b74e8541b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa32eed5bc38e85193e1aa23b74e8541b">&#9670;&nbsp;</a></span>statevec_controlledRotateX()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledRotateX </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00343">343</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;                                                                                            {</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160; </div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = {1, 0, 0};</div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;    <a class="code" href="QuEST__common_8c.html#a336c3286d2434fc892ebe20e9fa22a24">statevec_controlledRotateAroundAxis</a>(qureg, controlQubit, targetQubit, angle, unitAxis);</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00327">statevec_controlledRotateAroundAxis()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00221">controlledRotateX()</a>.</p>

</div>
</div>
<a id="ade67874c89179541f616b3685595d3ae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ade67874c89179541f616b3685595d3ae">&#9670;&nbsp;</a></span>statevec_controlledRotateY()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledRotateY </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00349">349</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;                                                                                            {</div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160; </div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = {0, 1, 0};</div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;    <a class="code" href="QuEST__common_8c.html#a336c3286d2434fc892ebe20e9fa22a24">statevec_controlledRotateAroundAxis</a>(qureg, controlQubit, targetQubit, angle, unitAxis);</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00327">statevec_controlledRotateAroundAxis()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00233">controlledRotateY()</a>.</p>

</div>
</div>
<a id="a3e11a9b9fa5ee16d4738a97f4590ee61"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3e11a9b9fa5ee16d4738a97f4590ee61">&#9670;&nbsp;</a></span>statevec_controlledRotateZ()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledRotateZ </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00355">355</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;                                                                                            {</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160; </div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = {0, 0, 1};</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;    <a class="code" href="QuEST__common_8c.html#a336c3286d2434fc892ebe20e9fa22a24">statevec_controlledRotateAroundAxis</a>(qureg, controlQubit, targetQubit, angle, unitAxis);</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00327">statevec_controlledRotateAroundAxis()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00245">controlledRotateZ()</a>.</p>

</div>
</div>
<a id="ad7ac4934371d72e24c6d1cea3d3da391"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad7ac4934371d72e24c6d1cea3d3da391">&#9670;&nbsp;</a></span>statevec_controlledTwoQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledTwoQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00523">523</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00523"></a><span class="lineno">  523</span>&#160;                                                                                                                             {</div>
<div class="line"><a name="l00524"></a><span class="lineno">  524</span>&#160;    </div>
<div class="line"><a name="l00525"></a><span class="lineno">  525</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> ctrlMask = 1LL &lt;&lt; controlQubit;</div>
<div class="line"><a name="l00526"></a><span class="lineno">  526</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a3eadcb581f2623e21e4967f791d0439c">statevec_multiControlledTwoQubitUnitary</a>(qureg, ctrlMask, targetQubit1, targetQubit2, u);</div>
<div class="line"><a name="l00527"></a><span class="lineno">  527</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">statevec_multiControlledTwoQubitUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00270">controlledTwoQubitUnitary()</a>.</p>

</div>
</div>
<a id="add9ca9956cdd81ed5d0b0f66168c04a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#add9ca9956cdd81ed5d0b0f66168c04a3">&#9670;&nbsp;</a></span>statevec_controlledUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">958</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00960"></a><span class="lineno">  960</span>&#160;{</div>
<div class="line"><a name="l00961"></a><span class="lineno">  961</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00962"></a><span class="lineno">  962</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00963"></a><span class="lineno">  963</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00964"></a><span class="lineno">  964</span>&#160; </div>
<div class="line"><a name="l00965"></a><span class="lineno">  965</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00966"></a><span class="lineno">  966</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00967"></a><span class="lineno">  967</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00968"></a><span class="lineno">  968</span>&#160; </div>
<div class="line"><a name="l00969"></a><span class="lineno">  969</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00970"></a><span class="lineno">  970</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00971"></a><span class="lineno">  971</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a903beb4f5d8753a964ce2dc5f9096a24">statevec_controlledUnitaryLocal</a>(qureg, controlQubit, targetQubit, u);</div>
<div class="line"><a name="l00972"></a><span class="lineno">  972</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00973"></a><span class="lineno">  973</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00974"></a><span class="lineno">  974</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00975"></a><span class="lineno">  975</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a>(rankIsUpper, &amp;rot1, &amp;rot2, u);</div>
<div class="line"><a name="l00976"></a><span class="lineno">  976</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00977"></a><span class="lineno">  977</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l00978"></a><span class="lineno">  978</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00979"></a><span class="lineno">  979</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00980"></a><span class="lineno">  980</span>&#160; </div>
<div class="line"><a name="l00981"></a><span class="lineno">  981</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to controlledUnitaryDistributed</span></div>
<div class="line"><a name="l00982"></a><span class="lineno">  982</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l00983"></a><span class="lineno">  983</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00984"></a><span class="lineno">  984</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00985"></a><span class="lineno">  985</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00986"></a><span class="lineno">  986</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00987"></a><span class="lineno">  987</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00988"></a><span class="lineno">  988</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00989"></a><span class="lineno">  989</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00990"></a><span class="lineno">  990</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00991"></a><span class="lineno">  991</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00992"></a><span class="lineno">  992</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00993"></a><span class="lineno">  993</span>&#160;        }</div>
<div class="line"><a name="l00994"></a><span class="lineno">  994</span>&#160;    }</div>
<div class="line"><a name="l00995"></a><span class="lineno">  995</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02381">statevec_controlledUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02241">statevec_controlledUnitaryLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00361">controlledUnitary()</a>.</p>

</div>
</div>
<a id="a365bbb1b80cb00405c8bf1a4fa1ea8e5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a365bbb1b80cb00405c8bf1a4fa1ea8e5">&#9670;&nbsp;</a></span>statevec_createQureg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_createQureg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> *&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01279">1279</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01280"></a><span class="lineno"> 1280</span>&#160;{</div>
<div class="line"><a name="l01281"></a><span class="lineno"> 1281</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = 1LL &lt;&lt; numQubits;</div>
<div class="line"><a name="l01282"></a><span class="lineno"> 1282</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmpsPerRank = numAmps/env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>;</div>
<div class="line"><a name="l01283"></a><span class="lineno"> 1283</span>&#160;    </div>
<div class="line"><a name="l01284"></a><span class="lineno"> 1284</span>&#160;    <span class="keywordflow">if</span> (numAmpsPerRank &gt; SIZE_MAX) {</div>
<div class="line"><a name="l01285"></a><span class="lineno"> 1285</span>&#160;        printf(<span class="stringliteral">&quot;Could not allocate memory (cannot fit numAmps into size_t)!&quot;</span>);</div>
<div class="line"><a name="l01286"></a><span class="lineno"> 1286</span>&#160;        exit (EXIT_FAILURE);</div>
<div class="line"><a name="l01287"></a><span class="lineno"> 1287</span>&#160;    }</div>
<div class="line"><a name="l01288"></a><span class="lineno"> 1288</span>&#160; </div>
<div class="line"><a name="l01289"></a><span class="lineno"> 1289</span>&#160;    <span class="keywordtype">size_t</span> arrSize = (size_t) (numAmpsPerRank * <span class="keyword">sizeof</span>(*(qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real)));</div>
<div class="line"><a name="l01290"></a><span class="lineno"> 1290</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real = malloc(arrSize);</div>
<div class="line"><a name="l01291"></a><span class="lineno"> 1291</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag = malloc(arrSize);</div>
<div class="line"><a name="l01292"></a><span class="lineno"> 1292</span>&#160;    <span class="keywordflow">if</span> (env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>&gt;1){</div>
<div class="line"><a name="l01293"></a><span class="lineno"> 1293</span>&#160;        qureg-&gt;<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real = malloc(arrSize);</div>
<div class="line"><a name="l01294"></a><span class="lineno"> 1294</span>&#160;        qureg-&gt;<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag = malloc(arrSize);</div>
<div class="line"><a name="l01295"></a><span class="lineno"> 1295</span>&#160;    }</div>
<div class="line"><a name="l01296"></a><span class="lineno"> 1296</span>&#160; </div>
<div class="line"><a name="l01297"></a><span class="lineno"> 1297</span>&#160;    <span class="keywordflow">if</span> ( (!(qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real) || !(qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag))</div>
<div class="line"><a name="l01298"></a><span class="lineno"> 1298</span>&#160;            &amp;&amp; numAmpsPerRank ) {</div>
<div class="line"><a name="l01299"></a><span class="lineno"> 1299</span>&#160;        printf(<span class="stringliteral">&quot;Could not allocate memory!&quot;</span>);</div>
<div class="line"><a name="l01300"></a><span class="lineno"> 1300</span>&#160;        exit (EXIT_FAILURE);</div>
<div class="line"><a name="l01301"></a><span class="lineno"> 1301</span>&#160;    }</div>
<div class="line"><a name="l01302"></a><span class="lineno"> 1302</span>&#160; </div>
<div class="line"><a name="l01303"></a><span class="lineno"> 1303</span>&#160;    <span class="keywordflow">if</span> ( env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>&gt;1 &amp;&amp; (!(qureg-&gt;<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real) || !(qureg-&gt;<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag))</div>
<div class="line"><a name="l01304"></a><span class="lineno"> 1304</span>&#160;            &amp;&amp; numAmpsPerRank ) {</div>
<div class="line"><a name="l01305"></a><span class="lineno"> 1305</span>&#160;        printf(<span class="stringliteral">&quot;Could not allocate memory!&quot;</span>);</div>
<div class="line"><a name="l01306"></a><span class="lineno"> 1306</span>&#160;        exit (EXIT_FAILURE);</div>
<div class="line"><a name="l01307"></a><span class="lineno"> 1307</span>&#160;    }</div>
<div class="line"><a name="l01308"></a><span class="lineno"> 1308</span>&#160; </div>
<div class="line"><a name="l01309"></a><span class="lineno"> 1309</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a> = numQubits;</div>
<div class="line"><a name="l01310"></a><span class="lineno"> 1310</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> = numAmps;</div>
<div class="line"><a name="l01311"></a><span class="lineno"> 1311</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> = numAmpsPerRank;</div>
<div class="line"><a name="l01312"></a><span class="lineno"> 1312</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> = env.<a class="code" href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">rank</a>;</div>
<div class="line"><a name="l01313"></a><span class="lineno"> 1313</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> = env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>;</div>
<div class="line"><a name="l01314"></a><span class="lineno"> 1314</span>&#160;    qureg-&gt;<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> = 0;</div>
<div class="line"><a name="l01315"></a><span class="lineno"> 1315</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00210">Qureg::numQubitsInStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00245">QuESTEnv::numRanks</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00244">QuESTEnv::rank</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00019">REDUCE_SHARED_SIZE</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00064">createCloneQureg()</a>, <a class="el" href="QuEST_8c_source.html#l00050">createDensityQureg()</a>, and <a class="el" href="QuEST_8c_source.html#l00036">createQureg()</a>.</p>

</div>
</div>
<a id="a2a52ad9f9ad9b2fd6a76f6d433b3b217"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a52ad9f9ad9b2fd6a76f6d433b3b217">&#9670;&nbsp;</a></span>statevec_destroyQureg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_destroyQureg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01317">1317</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01317"></a><span class="lineno"> 1317</span>&#160;                                                     {</div>
<div class="line"><a name="l01318"></a><span class="lineno"> 1318</span>&#160; </div>
<div class="line"><a name="l01319"></a><span class="lineno"> 1319</span>&#160;    qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a> = 0;</div>
<div class="line"><a name="l01320"></a><span class="lineno"> 1320</span>&#160;    qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> = 0;</div>
<div class="line"><a name="l01321"></a><span class="lineno"> 1321</span>&#160;    qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> = 0;</div>
<div class="line"><a name="l01322"></a><span class="lineno"> 1322</span>&#160; </div>
<div class="line"><a name="l01323"></a><span class="lineno"> 1323</span>&#160;    free(qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real);</div>
<div class="line"><a name="l01324"></a><span class="lineno"> 1324</span>&#160;    free(qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag);</div>
<div class="line"><a name="l01325"></a><span class="lineno"> 1325</span>&#160;    <span class="keywordflow">if</span> (env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>&gt;1){</div>
<div class="line"><a name="l01326"></a><span class="lineno"> 1326</span>&#160;        free(qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real);</div>
<div class="line"><a name="l01327"></a><span class="lineno"> 1327</span>&#160;        free(qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag);</div>
<div class="line"><a name="l01328"></a><span class="lineno"> 1328</span>&#160;    }</div>
<div class="line"><a name="l01329"></a><span class="lineno"> 1329</span>&#160;    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real = NULL;</div>
<div class="line"><a name="l01330"></a><span class="lineno"> 1330</span>&#160;    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag = NULL;</div>
<div class="line"><a name="l01331"></a><span class="lineno"> 1331</span>&#160;    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real = NULL;</div>
<div class="line"><a name="l01332"></a><span class="lineno"> 1332</span>&#160;    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag = NULL;</div>
<div class="line"><a name="l01333"></a><span class="lineno"> 1333</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::firstLevelReduction</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="QuEST_8h_source.html#l00210">Qureg::numQubitsInStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00245">QuESTEnv::numRanks</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00229">Qureg::secondLevelReduction</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00077">destroyQureg()</a>.</p>

</div>
</div>
<a id="abd509244d57657e148e4084c5ab5d28f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abd509244d57657e148e4084c5ab5d28f">&#9670;&nbsp;</a></span>statevec_getImagAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_getImagAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">208</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;                                                           {</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    <span class="keywordtype">int</span> chunkId = <a class="code" href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a>(qureg, index);</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> el; </div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==chunkId){</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;        el = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index-chunkId*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>];</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    }</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    MPI_Bcast(&amp;el, 1, MPI_QuEST_REAL, chunkId, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    <span class="keywordflow">return</span> el; </div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00194">getChunkIdFromIndex()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00699">getAmp()</a>, <a class="el" href="QuEST_8c_source.html#l00709">getDensityAmp()</a>, <a class="el" href="QuEST_8c_source.html#l00685">getImagAmp()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00245">statevec_getProbAmp()</a>.</p>

</div>
</div>
<a id="a3afe58e49dce5536bc4c1b7caddf44a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3afe58e49dce5536bc4c1b7caddf44a6">&#9670;&nbsp;</a></span>statevec_getProbAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_getProbAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00245">245</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;                                                           {</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> real = <a class="code" href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a>(qureg, index);</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> imag = <a class="code" href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a>(qureg, index);</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;    <span class="keywordflow">return</span> real*real + imag*imag;</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">statevec_getImagAmp()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">statevec_getRealAmp()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00692">getProbAmp()</a>.</p>

</div>
</div>
<a id="abc9a9ef4344c7faaaf28ac25c76649b9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abc9a9ef4344c7faaaf28ac25c76649b9">&#9670;&nbsp;</a></span>statevec_getRealAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_getRealAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">198</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;                                                           {</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    <span class="keywordtype">int</span> chunkId = <a class="code" href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a>(qureg, index);</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> el; </div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==chunkId){</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;        el = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index-chunkId*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>];</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;    }</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    MPI_Bcast(&amp;el, 1, MPI_QuEST_REAL, chunkId, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    <span class="keywordflow">return</span> el; </div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;} </div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00194">getChunkIdFromIndex()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00699">getAmp()</a>, <a class="el" href="QuEST_8c_source.html#l00709">getDensityAmp()</a>, <a class="el" href="QuEST_8c_source.html#l00678">getRealAmp()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00245">statevec_getProbAmp()</a>.</p>

</div>
</div>
<a id="af3fc7bd149c70f083b149050242cd55e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af3fc7bd149c70f083b149050242cd55e">&#9670;&nbsp;</a></span>statevec_hadamard()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_hadamard </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01206">1206</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01207"></a><span class="lineno"> 1207</span>&#160;{</div>
<div class="line"><a name="l01208"></a><span class="lineno"> 1208</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01209"></a><span class="lineno"> 1209</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01210"></a><span class="lineno"> 1210</span>&#160; </div>
<div class="line"><a name="l01211"></a><span class="lineno"> 1211</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01212"></a><span class="lineno"> 1212</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l01213"></a><span class="lineno"> 1213</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01214"></a><span class="lineno"> 1214</span>&#160; </div>
<div class="line"><a name="l01215"></a><span class="lineno"> 1215</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01216"></a><span class="lineno"> 1216</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01217"></a><span class="lineno"> 1217</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a86dbcc3db99294add9964741e19fbdab">statevec_hadamardLocal</a>(qureg, targetQubit);</div>
<div class="line"><a name="l01218"></a><span class="lineno"> 1218</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01219"></a><span class="lineno"> 1219</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01220"></a><span class="lineno"> 1220</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01221"></a><span class="lineno"> 1221</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01222"></a><span class="lineno"> 1222</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l01223"></a><span class="lineno"> 1223</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01224"></a><span class="lineno"> 1224</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01225"></a><span class="lineno"> 1225</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to hadamardDistributed</span></div>
<div class="line"><a name="l01226"></a><span class="lineno"> 1226</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l01227"></a><span class="lineno"> 1227</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01228"></a><span class="lineno"> 1228</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a>(qureg,</div>
<div class="line"><a name="l01229"></a><span class="lineno"> 1229</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01230"></a><span class="lineno"> 1230</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01231"></a><span class="lineno"> 1231</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, rankIsUpper); <span class="comment">//output</span></div>
<div class="line"><a name="l01232"></a><span class="lineno"> 1232</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01233"></a><span class="lineno"> 1233</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a>(qureg,</div>
<div class="line"><a name="l01234"></a><span class="lineno"> 1234</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01235"></a><span class="lineno"> 1235</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01236"></a><span class="lineno"> 1236</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, rankIsUpper); <span class="comment">//output</span></div>
<div class="line"><a name="l01237"></a><span class="lineno"> 1237</span>&#160;        }</div>
<div class="line"><a name="l01238"></a><span class="lineno"> 1238</span>&#160;    }</div>
<div class="line"><a name="l01239"></a><span class="lineno"> 1239</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02932">statevec_hadamardDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02872">statevec_hadamardLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00177">hadamard()</a>.</p>

</div>
</div>
<a id="a758bad4237ff0bf3b4ff5be626a982ae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a758bad4237ff0bf3b4ff5be626a982ae">&#9670;&nbsp;</a></span>statevec_initBlankState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_initBlankState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01398">1398</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01399"></a><span class="lineno"> 1399</span>&#160;{</div>
<div class="line"><a name="l01400"></a><span class="lineno"> 1400</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l01401"></a><span class="lineno"> 1401</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01402"></a><span class="lineno"> 1402</span>&#160; </div>
<div class="line"><a name="l01403"></a><span class="lineno"> 1403</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01404"></a><span class="lineno"> 1404</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01405"></a><span class="lineno"> 1405</span>&#160; </div>
<div class="line"><a name="l01406"></a><span class="lineno"> 1406</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01407"></a><span class="lineno"> 1407</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01408"></a><span class="lineno"> 1408</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01409"></a><span class="lineno"> 1409</span>&#160; </div>
<div class="line"><a name="l01410"></a><span class="lineno"> 1410</span>&#160;    <span class="comment">// initialise the state-vector to all-zeroes</span></div>
<div class="line"><a name="l01411"></a><span class="lineno"> 1411</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01412"></a><span class="lineno"> 1412</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01413"></a><span class="lineno"> 1413</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01414"></a><span class="lineno"> 1414</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal, stateVecImag) \</span></div>
<div class="line"><a name="l01415"></a><span class="lineno"> 1415</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01416"></a><span class="lineno"> 1416</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01417"></a><span class="lineno"> 1417</span>&#160;    {</div>
<div class="line"><a name="l01418"></a><span class="lineno"> 1418</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01419"></a><span class="lineno"> 1419</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01420"></a><span class="lineno"> 1420</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01421"></a><span class="lineno"> 1421</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l01422"></a><span class="lineno"> 1422</span>&#160;            stateVecReal[index] = 0.0;</div>
<div class="line"><a name="l01423"></a><span class="lineno"> 1423</span>&#160;            stateVecImag[index] = 0.0;</div>
<div class="line"><a name="l01424"></a><span class="lineno"> 1424</span>&#160;        }</div>
<div class="line"><a name="l01425"></a><span class="lineno"> 1425</span>&#160;    }</div>
<div class="line"><a name="l01426"></a><span class="lineno"> 1426</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00119">initBlankState()</a>, <a class="el" href="QuEST__common_8c_source.html#l00494">statevec_applyPauliSum()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01428">statevec_initZeroState()</a>.</p>

</div>
</div>
<a id="a288dc4b46bdacd69cbf4a6fd070d26a7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a288dc4b46bdacd69cbf4a6fd070d26a7">&#9670;&nbsp;</a></span>statevec_initClassicalState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_initClassicalState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>stateInd</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01470">1470</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01471"></a><span class="lineno"> 1471</span>&#160;{</div>
<div class="line"><a name="l01472"></a><span class="lineno"> 1472</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l01473"></a><span class="lineno"> 1473</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01474"></a><span class="lineno"> 1474</span>&#160; </div>
<div class="line"><a name="l01475"></a><span class="lineno"> 1475</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01476"></a><span class="lineno"> 1476</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01477"></a><span class="lineno"> 1477</span>&#160; </div>
<div class="line"><a name="l01478"></a><span class="lineno"> 1478</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01479"></a><span class="lineno"> 1479</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01480"></a><span class="lineno"> 1480</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01481"></a><span class="lineno"> 1481</span>&#160; </div>
<div class="line"><a name="l01482"></a><span class="lineno"> 1482</span>&#160;    <span class="comment">// initialise the state to vector to all zeros</span></div>
<div class="line"><a name="l01483"></a><span class="lineno"> 1483</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01484"></a><span class="lineno"> 1484</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01485"></a><span class="lineno"> 1485</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01486"></a><span class="lineno"> 1486</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal, stateVecImag) \</span></div>
<div class="line"><a name="l01487"></a><span class="lineno"> 1487</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01488"></a><span class="lineno"> 1488</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01489"></a><span class="lineno"> 1489</span>&#160;    {</div>
<div class="line"><a name="l01490"></a><span class="lineno"> 1490</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01491"></a><span class="lineno"> 1491</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01492"></a><span class="lineno"> 1492</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01493"></a><span class="lineno"> 1493</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l01494"></a><span class="lineno"> 1494</span>&#160;            stateVecReal[index] = 0.0;</div>
<div class="line"><a name="l01495"></a><span class="lineno"> 1495</span>&#160;            stateVecImag[index] = 0.0;</div>
<div class="line"><a name="l01496"></a><span class="lineno"> 1496</span>&#160;        }</div>
<div class="line"><a name="l01497"></a><span class="lineno"> 1497</span>&#160;    }</div>
<div class="line"><a name="l01498"></a><span class="lineno"> 1498</span>&#160; </div>
<div class="line"><a name="l01499"></a><span class="lineno"> 1499</span>&#160;    <span class="comment">// give the specified classical state prob 1</span></div>
<div class="line"><a name="l01500"></a><span class="lineno"> 1500</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> == stateInd/stateVecSize){</div>
<div class="line"><a name="l01501"></a><span class="lineno"> 1501</span>&#160;        stateVecReal[stateInd % stateVecSize] = 1.0;</div>
<div class="line"><a name="l01502"></a><span class="lineno"> 1502</span>&#160;        stateVecImag[stateInd % stateVecSize] = 0.0;</div>
<div class="line"><a name="l01503"></a><span class="lineno"> 1503</span>&#160;    }</div>
<div class="line"><a name="l01504"></a><span class="lineno"> 1504</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00134">initClassicalState()</a>.</p>

</div>
</div>
<a id="ad9fd3017ea40cf63fd04b39e03494972"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad9fd3017ea40cf63fd04b39e03494972">&#9670;&nbsp;</a></span>statevec_initDebugState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_initDebugState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialise the state vector of probability amplitudes to an (unphysical) state with each component of each probability amplitude a unique floating point value. </p>
<p>For debugging processes </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of qubits to be initialised </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01591">1591</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01592"></a><span class="lineno"> 1592</span>&#160;{</div>
<div class="line"><a name="l01593"></a><span class="lineno"> 1593</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize;</div>
<div class="line"><a name="l01594"></a><span class="lineno"> 1594</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01595"></a><span class="lineno"> 1595</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> indexOffset;</div>
<div class="line"><a name="l01596"></a><span class="lineno"> 1596</span>&#160; </div>
<div class="line"><a name="l01597"></a><span class="lineno"> 1597</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01598"></a><span class="lineno"> 1598</span>&#160;    chunkSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01599"></a><span class="lineno"> 1599</span>&#160; </div>
<div class="line"><a name="l01600"></a><span class="lineno"> 1600</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01601"></a><span class="lineno"> 1601</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01602"></a><span class="lineno"> 1602</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01603"></a><span class="lineno"> 1603</span>&#160; </div>
<div class="line"><a name="l01604"></a><span class="lineno"> 1604</span>&#160;    indexOffset = chunkSize * qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l01605"></a><span class="lineno"> 1605</span>&#160; </div>
<div class="line"><a name="l01606"></a><span class="lineno"> 1606</span>&#160;    <span class="comment">// initialise the state to |0000..0000&gt;</span></div>
<div class="line"><a name="l01607"></a><span class="lineno"> 1607</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01608"></a><span class="lineno"> 1608</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01609"></a><span class="lineno"> 1609</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01610"></a><span class="lineno"> 1610</span>&#160;<span class="preprocessor">    shared   (chunkSize, stateVecReal, stateVecImag, indexOffset) \</span></div>
<div class="line"><a name="l01611"></a><span class="lineno"> 1611</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01612"></a><span class="lineno"> 1612</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01613"></a><span class="lineno"> 1613</span>&#160;    {</div>
<div class="line"><a name="l01614"></a><span class="lineno"> 1614</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01615"></a><span class="lineno"> 1615</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01616"></a><span class="lineno"> 1616</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01617"></a><span class="lineno"> 1617</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;chunkSize; index++) {</div>
<div class="line"><a name="l01618"></a><span class="lineno"> 1618</span>&#160;            stateVecReal[index] = ((indexOffset + index)*2.0)/10.0;</div>
<div class="line"><a name="l01619"></a><span class="lineno"> 1619</span>&#160;            stateVecImag[index] = ((indexOffset + index)*2.0+1.0)/10.0;</div>
<div class="line"><a name="l01620"></a><span class="lineno"> 1620</span>&#160;        }</div>
<div class="line"><a name="l01621"></a><span class="lineno"> 1621</span>&#160;    }</div>
<div class="line"><a name="l01622"></a><span class="lineno"> 1622</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01308">initDebugState()</a>.</p>

</div>
</div>
<a id="a482fc361fd5f08075404c72e536316a0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a482fc361fd5f08075404c72e536316a0">&#9670;&nbsp;</a></span>statevec_initPlusState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_initPlusState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01438">1438</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01439"></a><span class="lineno"> 1439</span>&#160;{</div>
<div class="line"><a name="l01440"></a><span class="lineno"> 1440</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize, stateVecSize;</div>
<div class="line"><a name="l01441"></a><span class="lineno"> 1441</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01442"></a><span class="lineno"> 1442</span>&#160; </div>
<div class="line"><a name="l01443"></a><span class="lineno"> 1443</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01444"></a><span class="lineno"> 1444</span>&#160;    chunkSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01445"></a><span class="lineno"> 1445</span>&#160;    stateVecSize = chunkSize*qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>;</div>
<div class="line"><a name="l01446"></a><span class="lineno"> 1446</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> normFactor = 1.0/sqrt((<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>)stateVecSize);</div>
<div class="line"><a name="l01447"></a><span class="lineno"> 1447</span>&#160; </div>
<div class="line"><a name="l01448"></a><span class="lineno"> 1448</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01449"></a><span class="lineno"> 1449</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01450"></a><span class="lineno"> 1450</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01451"></a><span class="lineno"> 1451</span>&#160; </div>
<div class="line"><a name="l01452"></a><span class="lineno"> 1452</span>&#160;    <span class="comment">// initialise the state to |+++..+++&gt; = 1/normFactor {1, 1, 1, ...}</span></div>
<div class="line"><a name="l01453"></a><span class="lineno"> 1453</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01454"></a><span class="lineno"> 1454</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01455"></a><span class="lineno"> 1455</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01456"></a><span class="lineno"> 1456</span>&#160;<span class="preprocessor">    shared   (chunkSize, stateVecReal, stateVecImag, normFactor) \</span></div>
<div class="line"><a name="l01457"></a><span class="lineno"> 1457</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01458"></a><span class="lineno"> 1458</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01459"></a><span class="lineno"> 1459</span>&#160;    {</div>
<div class="line"><a name="l01460"></a><span class="lineno"> 1460</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01461"></a><span class="lineno"> 1461</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01462"></a><span class="lineno"> 1462</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01463"></a><span class="lineno"> 1463</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;chunkSize; index++) {</div>
<div class="line"><a name="l01464"></a><span class="lineno"> 1464</span>&#160;            stateVecReal[index] = normFactor;</div>
<div class="line"><a name="l01465"></a><span class="lineno"> 1465</span>&#160;            stateVecImag[index] = 0.0;</div>
<div class="line"><a name="l01466"></a><span class="lineno"> 1466</span>&#160;        }</div>
<div class="line"><a name="l01467"></a><span class="lineno"> 1467</span>&#160;    }</div>
<div class="line"><a name="l01468"></a><span class="lineno"> 1468</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00125">initPlusState()</a>.</p>

</div>
</div>
<a id="a05756b45f10135bb2eeb07380f806c20"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a05756b45f10135bb2eeb07380f806c20">&#9670;&nbsp;</a></span>statevec_initStateFromSingleFile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int statevec_initStateFromSingleFile </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> *&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>filename</em>[200], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01625">1625</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01625"></a><span class="lineno"> 1625</span>&#160;                                                                                    {</div>
<div class="line"><a name="l01626"></a><span class="lineno"> 1626</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize, stateVecSize;</div>
<div class="line"><a name="l01627"></a><span class="lineno"> 1627</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> indexInChunk, totalIndex;</div>
<div class="line"><a name="l01628"></a><span class="lineno"> 1628</span>&#160; </div>
<div class="line"><a name="l01629"></a><span class="lineno"> 1629</span>&#160;    chunkSize = qureg-&gt;<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01630"></a><span class="lineno"> 1630</span>&#160;    stateVecSize = chunkSize*qureg-&gt;<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>;</div>
<div class="line"><a name="l01631"></a><span class="lineno"> 1631</span>&#160; </div>
<div class="line"><a name="l01632"></a><span class="lineno"> 1632</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01633"></a><span class="lineno"> 1633</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01634"></a><span class="lineno"> 1634</span>&#160; </div>
<div class="line"><a name="l01635"></a><span class="lineno"> 1635</span>&#160;    FILE *fp;</div>
<div class="line"><a name="l01636"></a><span class="lineno"> 1636</span>&#160;    <span class="keywordtype">char</span> line[200];</div>
<div class="line"><a name="l01637"></a><span class="lineno"> 1637</span>&#160; </div>
<div class="line"><a name="l01638"></a><span class="lineno"> 1638</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> rank=0; rank&lt;(qureg-&gt;<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>); rank++){</div>
<div class="line"><a name="l01639"></a><span class="lineno"> 1639</span>&#160;        <span class="keywordflow">if</span> (rank==qureg-&gt;<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>){</div>
<div class="line"><a name="l01640"></a><span class="lineno"> 1640</span>&#160;            fp = fopen(filename, <span class="stringliteral">&quot;r&quot;</span>);</div>
<div class="line"><a name="l01641"></a><span class="lineno"> 1641</span>&#160;            </div>
<div class="line"><a name="l01642"></a><span class="lineno"> 1642</span>&#160;            <span class="comment">// indicate file open failure</span></div>
<div class="line"><a name="l01643"></a><span class="lineno"> 1643</span>&#160;            <span class="keywordflow">if</span> (fp == NULL)</div>
<div class="line"><a name="l01644"></a><span class="lineno"> 1644</span>&#160;                <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l01645"></a><span class="lineno"> 1645</span>&#160;            </div>
<div class="line"><a name="l01646"></a><span class="lineno"> 1646</span>&#160;            indexInChunk = 0; totalIndex = 0;</div>
<div class="line"><a name="l01647"></a><span class="lineno"> 1647</span>&#160;            <span class="keywordflow">while</span> (fgets(line, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)*200, fp) != NULL &amp;&amp; totalIndex&lt;stateVecSize){</div>
<div class="line"><a name="l01648"></a><span class="lineno"> 1648</span>&#160;                <span class="keywordflow">if</span> (line[0]!=<span class="charliteral">&#39;#&#39;</span>){</div>
<div class="line"><a name="l01649"></a><span class="lineno"> 1649</span>&#160;                    <span class="keywordtype">int</span> chunkId = (int) (totalIndex/chunkSize);</div>
<div class="line"><a name="l01650"></a><span class="lineno"> 1650</span>&#160;                    <span class="keywordflow">if</span> (chunkId==qureg-&gt;<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>){</div>
<div class="line"><a name="l01651"></a><span class="lineno"> 1651</span>&#160;<span class="preprocessor">                        # if QuEST_PREC==1</span></div>
<div class="line"><a name="l01652"></a><span class="lineno"> 1652</span>&#160;                        sscanf(line, <span class="stringliteral">&quot;%f, %f&quot;</span>, &amp;(stateVecReal[indexInChunk]), </div>
<div class="line"><a name="l01653"></a><span class="lineno"> 1653</span>&#160;                                &amp;(stateVecImag[indexInChunk])); </div>
<div class="line"><a name="l01654"></a><span class="lineno"> 1654</span>&#160;<span class="preprocessor">                        # elif QuEST_PREC==2                    </span></div>
<div class="line"><a name="l01655"></a><span class="lineno"> 1655</span>&#160;                        sscanf(line, <span class="stringliteral">&quot;%lf, %lf&quot;</span>, &amp;(stateVecReal[indexInChunk]), </div>
<div class="line"><a name="l01656"></a><span class="lineno"> 1656</span>&#160;                                &amp;(stateVecImag[indexInChunk]));</div>
<div class="line"><a name="l01657"></a><span class="lineno"> 1657</span>&#160;<span class="preprocessor">                        # elif QuEST_PREC==4</span></div>
<div class="line"><a name="l01658"></a><span class="lineno"> 1658</span>&#160;                        sscanf(line, <span class="stringliteral">&quot;%Lf, %Lf&quot;</span>, &amp;(stateVecReal[indexInChunk]), </div>
<div class="line"><a name="l01659"></a><span class="lineno"> 1659</span>&#160;                                &amp;(stateVecImag[indexInChunk]));</div>
<div class="line"><a name="l01660"></a><span class="lineno"> 1660</span>&#160;<span class="preprocessor">                        # endif</span></div>
<div class="line"><a name="l01661"></a><span class="lineno"> 1661</span>&#160;                        indexInChunk += 1;</div>
<div class="line"><a name="l01662"></a><span class="lineno"> 1662</span>&#160;                    }</div>
<div class="line"><a name="l01663"></a><span class="lineno"> 1663</span>&#160;                    totalIndex += 1;</div>
<div class="line"><a name="l01664"></a><span class="lineno"> 1664</span>&#160;                }</div>
<div class="line"><a name="l01665"></a><span class="lineno"> 1665</span>&#160;            }   </div>
<div class="line"><a name="l01666"></a><span class="lineno"> 1666</span>&#160;            fclose(fp);</div>
<div class="line"><a name="l01667"></a><span class="lineno"> 1667</span>&#160;        }</div>
<div class="line"><a name="l01668"></a><span class="lineno"> 1668</span>&#160;        <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(env);</div>
<div class="line"><a name="l01669"></a><span class="lineno"> 1669</span>&#160;    }</div>
<div class="line"><a name="l01670"></a><span class="lineno"> 1670</span>&#160;    </div>
<div class="line"><a name="l01671"></a><span class="lineno"> 1671</span>&#160;    <span class="comment">// indicate success</span></div>
<div class="line"><a name="l01672"></a><span class="lineno"> 1672</span>&#160;    <span class="keywordflow">return</span> 1;</div>
<div class="line"><a name="l01673"></a><span class="lineno"> 1673</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00451">copyStateToGPU()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01312">initStateFromSingleFile()</a>.</p>

</div>
</div>
<a id="a923906770cac0da9e3459bae58de9e64"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a923906770cac0da9e3459bae58de9e64">&#9670;&nbsp;</a></span>statevec_initStateOfSingleQubit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_initStateOfSingleQubit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> *&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubitId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialise the state vector of probability amplitudes such that one qubit is set to 'outcome' and all other qubits are in an equal superposition of zero and one. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of qubits to be initialised </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">qubitId</td><td>id of qubit to set to state 'outcome' </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>of qubit 'qubitId' </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01545">1545</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01546"></a><span class="lineno"> 1546</span>&#160;{</div>
<div class="line"><a name="l01547"></a><span class="lineno"> 1547</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize, stateVecSize;</div>
<div class="line"><a name="l01548"></a><span class="lineno"> 1548</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01549"></a><span class="lineno"> 1549</span>&#160;    <span class="keywordtype">int</span> bit;</div>
<div class="line"><a name="l01550"></a><span class="lineno"> 1550</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg-&gt;<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l01551"></a><span class="lineno"> 1551</span>&#160; </div>
<div class="line"><a name="l01552"></a><span class="lineno"> 1552</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l01553"></a><span class="lineno"> 1553</span>&#160;    chunkSize = qureg-&gt;<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01554"></a><span class="lineno"> 1554</span>&#160;    stateVecSize = chunkSize*qureg-&gt;<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>;</div>
<div class="line"><a name="l01555"></a><span class="lineno"> 1555</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> normFactor = 1.0/sqrt((<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>)stateVecSize/2.0);</div>
<div class="line"><a name="l01556"></a><span class="lineno"> 1556</span>&#160; </div>
<div class="line"><a name="l01557"></a><span class="lineno"> 1557</span>&#160;    <span class="comment">// Can&#39;t use qureg-&gt;stateVec as a private OMP var</span></div>
<div class="line"><a name="l01558"></a><span class="lineno"> 1558</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01559"></a><span class="lineno"> 1559</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg-&gt;<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01560"></a><span class="lineno"> 1560</span>&#160; </div>
<div class="line"><a name="l01561"></a><span class="lineno"> 1561</span>&#160;    <span class="comment">// initialise the state to |0000..0000&gt;</span></div>
<div class="line"><a name="l01562"></a><span class="lineno"> 1562</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01563"></a><span class="lineno"> 1563</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01564"></a><span class="lineno"> 1564</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01565"></a><span class="lineno"> 1565</span>&#160;<span class="preprocessor">    shared   (chunkSize, stateVecReal, stateVecImag, normFactor, qubitId, outcome, chunkId) \</span></div>
<div class="line"><a name="l01566"></a><span class="lineno"> 1566</span>&#160;<span class="preprocessor">    private  (index, bit)</span></div>
<div class="line"><a name="l01567"></a><span class="lineno"> 1567</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01568"></a><span class="lineno"> 1568</span>&#160;    {</div>
<div class="line"><a name="l01569"></a><span class="lineno"> 1569</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01570"></a><span class="lineno"> 1570</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01571"></a><span class="lineno"> 1571</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01572"></a><span class="lineno"> 1572</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;chunkSize; index++) {</div>
<div class="line"><a name="l01573"></a><span class="lineno"> 1573</span>&#160;            bit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(qubitId, index+chunkId*chunkSize);</div>
<div class="line"><a name="l01574"></a><span class="lineno"> 1574</span>&#160;            <span class="keywordflow">if</span> (bit==outcome) {</div>
<div class="line"><a name="l01575"></a><span class="lineno"> 1575</span>&#160;                stateVecReal[index] = normFactor;</div>
<div class="line"><a name="l01576"></a><span class="lineno"> 1576</span>&#160;                stateVecImag[index] = 0.0;</div>
<div class="line"><a name="l01577"></a><span class="lineno"> 1577</span>&#160;            } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01578"></a><span class="lineno"> 1578</span>&#160;                stateVecReal[index] = 0.0;</div>
<div class="line"><a name="l01579"></a><span class="lineno"> 1579</span>&#160;                stateVecImag[index] = 0.0;</div>
<div class="line"><a name="l01580"></a><span class="lineno"> 1580</span>&#160;            }</div>
<div class="line"><a name="l01581"></a><span class="lineno"> 1581</span>&#160;        }</div>
<div class="line"><a name="l01582"></a><span class="lineno"> 1582</span>&#160;    }</div>
<div class="line"><a name="l01583"></a><span class="lineno"> 1583</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01317">initStateOfSingleQubit()</a>.</p>

</div>
</div>
<a id="a2ca0c6ba07ab2b4b437321bf17efc966"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2ca0c6ba07ab2b4b437321bf17efc966">&#9670;&nbsp;</a></span>statevec_initZeroState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_initZeroState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01428">1428</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01429"></a><span class="lineno"> 1429</span>&#160;{</div>
<div class="line"><a name="l01430"></a><span class="lineno"> 1430</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#a758bad4237ff0bf3b4ff5be626a982ae">statevec_initBlankState</a>(qureg);</div>
<div class="line"><a name="l01431"></a><span class="lineno"> 1431</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==0){</div>
<div class="line"><a name="l01432"></a><span class="lineno"> 1432</span>&#160;        <span class="comment">// zero state |0000..0000&gt; has probability 1</span></div>
<div class="line"><a name="l01433"></a><span class="lineno"> 1433</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[0] = 1.0;</div>
<div class="line"><a name="l01434"></a><span class="lineno"> 1434</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[0] = 0.0;</div>
<div class="line"><a name="l01435"></a><span class="lineno"> 1435</span>&#160;    }</div>
<div class="line"><a name="l01436"></a><span class="lineno"> 1436</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01398">statevec_initBlankState()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00113">initZeroState()</a>.</p>

</div>
</div>
<a id="ac2eb81c71d0e0fbec7be5b45b1db1448"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac2eb81c71d0e0fbec7be5b45b1db1448">&#9670;&nbsp;</a></span>statevec_measureWithStats()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int statevec_measureWithStats </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>outcomeProb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00361">361</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;                                                                                 {</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;    </div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> zeroProb = <a class="code" href="QuEST__internal_8h.html#a63cb88a5f4eb12fef087435b8db3f8eb">statevec_calcProbOfOutcome</a>(qureg, measureQubit, 0);</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;    <span class="keywordtype">int</span> outcome = <a class="code" href="QuEST__common_8c.html#a9d19fc690afb425d0df5feb09be567a3">generateMeasurementOutcome</a>(zeroProb, outcomeProb);</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a>(qureg, measureQubit, outcome, *outcomeProb);</div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;    <span class="keywordflow">return</span> outcome;</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00155">generateMeasurementOutcome()</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01260">statevec_calcProbOfOutcome()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01298">statevec_collapseToKnownProbOutcome()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00758">measure()</a>, and <a class="el" href="QuEST_8c_source.html#l00745">measureWithStats()</a>.</p>

</div>
</div>
<a id="a0acfe30083d0bc2a84da196378a36122"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0acfe30083d0bc2a84da196378a36122">&#9670;&nbsp;</a></span>statevec_multiControlledMultiQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledMultiQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct. </p>
<p>It is already gauranteed here that all target qubits can fit on each node (this is validated in the front-end)</p>
<p>@TODO: refactor so that the 'swap back' isn't performed; instead the qubit locations are updated. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">1437</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01437"></a><span class="lineno"> 1437</span>&#160;                                                                                                                                {</div>
<div class="line"><a name="l01438"></a><span class="lineno"> 1438</span>&#160; </div>
<div class="line"><a name="l01439"></a><span class="lineno"> 1439</span>&#160;    <span class="comment">// bit mask of target qubits (for quick collision checking)</span></div>
<div class="line"><a name="l01440"></a><span class="lineno"> 1440</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> targMask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(targs, numTargs);</div>
<div class="line"><a name="l01441"></a><span class="lineno"> 1441</span>&#160;    </div>
<div class="line"><a name="l01442"></a><span class="lineno"> 1442</span>&#160;    <span class="comment">// find lowest qubit available for swapping (isn&#39;t in targs)</span></div>
<div class="line"><a name="l01443"></a><span class="lineno"> 1443</span>&#160;    <span class="keywordtype">int</span> freeQb=0;</div>
<div class="line"><a name="l01444"></a><span class="lineno"> 1444</span>&#160;    <span class="keywordflow">while</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(targMask, freeQb))</div>
<div class="line"><a name="l01445"></a><span class="lineno"> 1445</span>&#160;        freeQb++;</div>
<div class="line"><a name="l01446"></a><span class="lineno"> 1446</span>&#160;        </div>
<div class="line"><a name="l01447"></a><span class="lineno"> 1447</span>&#160;    <span class="comment">// assign indices of where each target will be swapped to (else itself)</span></div>
<div class="line"><a name="l01448"></a><span class="lineno"> 1448</span>&#160;    <span class="keywordtype">int</span> swapTargs[numTargs];</div>
<div class="line"><a name="l01449"></a><span class="lineno"> 1449</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTargs; t++) {</div>
<div class="line"><a name="l01450"></a><span class="lineno"> 1450</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targs[t]))</div>
<div class="line"><a name="l01451"></a><span class="lineno"> 1451</span>&#160;            swapTargs[t] = targs[t];</div>
<div class="line"><a name="l01452"></a><span class="lineno"> 1452</span>&#160;        <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01453"></a><span class="lineno"> 1453</span>&#160;            <span class="comment">// mark swap</span></div>
<div class="line"><a name="l01454"></a><span class="lineno"> 1454</span>&#160;            swapTargs[t] = freeQb;</div>
<div class="line"><a name="l01455"></a><span class="lineno"> 1455</span>&#160;            </div>
<div class="line"><a name="l01456"></a><span class="lineno"> 1456</span>&#160;            <span class="comment">// update ctrlMask if swapped-out qubit was a control</span></div>
<div class="line"><a name="l01457"></a><span class="lineno"> 1457</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, swapTargs[t]))</div>
<div class="line"><a name="l01458"></a><span class="lineno"> 1458</span>&#160;                ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, swapTargs[t]), targs[t]); <span class="comment">// swap targ and ctrl</span></div>
<div class="line"><a name="l01459"></a><span class="lineno"> 1459</span>&#160;            </div>
<div class="line"><a name="l01460"></a><span class="lineno"> 1460</span>&#160;            <span class="comment">// locate next available on-chunk qubit</span></div>
<div class="line"><a name="l01461"></a><span class="lineno"> 1461</span>&#160;            freeQb++;</div>
<div class="line"><a name="l01462"></a><span class="lineno"> 1462</span>&#160;            <span class="keywordflow">while</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(targMask, freeQb))</div>
<div class="line"><a name="l01463"></a><span class="lineno"> 1463</span>&#160;                freeQb++;</div>
<div class="line"><a name="l01464"></a><span class="lineno"> 1464</span>&#160;        }</div>
<div class="line"><a name="l01465"></a><span class="lineno"> 1465</span>&#160;    }</div>
<div class="line"><a name="l01466"></a><span class="lineno"> 1466</span>&#160;    </div>
<div class="line"><a name="l01467"></a><span class="lineno"> 1467</span>&#160;    <span class="comment">// perform swaps as necessary </span></div>
<div class="line"><a name="l01468"></a><span class="lineno"> 1468</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTargs; t++)</div>
<div class="line"><a name="l01469"></a><span class="lineno"> 1469</span>&#160;        <span class="keywordflow">if</span> (swapTargs[t] != targs[t])</div>
<div class="line"><a name="l01470"></a><span class="lineno"> 1470</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, targs[t], swapTargs[t]);</div>
<div class="line"><a name="l01471"></a><span class="lineno"> 1471</span>&#160;    </div>
<div class="line"><a name="l01472"></a><span class="lineno"> 1472</span>&#160;    <span class="comment">// all target qubits have now been swapped into local memory</span></div>
<div class="line"><a name="l01473"></a><span class="lineno"> 1473</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#a0aedcccfa50c7aaa8b7fc4c14d7cdfb8">statevec_multiControlledMultiQubitUnitaryLocal</a>(qureg, ctrlMask, swapTargs, numTargs, u);</div>
<div class="line"><a name="l01474"></a><span class="lineno"> 1474</span>&#160;    </div>
<div class="line"><a name="l01475"></a><span class="lineno"> 1475</span>&#160;    <span class="comment">// undo swaps </span></div>
<div class="line"><a name="l01476"></a><span class="lineno"> 1476</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTargs; t++)</div>
<div class="line"><a name="l01477"></a><span class="lineno"> 1477</span>&#160;        <span class="keywordflow">if</span> (swapTargs[t] != targs[t])</div>
<div class="line"><a name="l01478"></a><span class="lineno"> 1478</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, targs[t], swapTargs[t]);</div>
<div class="line"><a name="l01479"></a><span class="lineno"> 1479</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, <a class="el" href="QuEST__common_8c_source.html#l00044">getQubitBitMask()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00140">ComplexMatrixN::imag</a>, <a class="el" href="QuEST__cpu__internal_8h_source.html#l00034">maskContainsBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00138">ComplexMatrixN::numQubits</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00139">ComplexMatrixN::real</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01846">statevec_multiControlledMultiQubitUnitaryLocal()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00874">applyMultiControlledMatrixN()</a>, <a class="el" href="QuEST__common_8c_source.html#l00590">densmatr_applyMultiQubitKrausSuperoperator()</a>, <a class="el" href="QuEST__common_8c_source.html#l00582">densmatr_applyTwoQubitKrausSuperoperator()</a>, <a class="el" href="QuEST_8c_source.html#l00331">multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST__common_8c_source.html#l00535">statevec_controlledMultiQubitUnitary()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00529">statevec_multiQubitUnitary()</a>.</p>

</div>
</div>
<a id="ac4ee5979d475e8c729294b8ef7e0270d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac4ee5979d475e8c729294b8ef7e0270d">&#9670;&nbsp;</a></span>statevec_multiControlledPhaseFlip()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledPhaseFlip </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>controlQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numControlQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03331">3331</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03332"></a><span class="lineno"> 3332</span>&#160;{</div>
<div class="line"><a name="l03333"></a><span class="lineno"> 3333</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03334"></a><span class="lineno"> 3334</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l03335"></a><span class="lineno"> 3335</span>&#160; </div>
<div class="line"><a name="l03336"></a><span class="lineno"> 3336</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03337"></a><span class="lineno"> 3337</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l03338"></a><span class="lineno"> 3338</span>&#160; </div>
<div class="line"><a name="l03339"></a><span class="lineno"> 3339</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> mask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(controlQubits, numControlQubits);</div>
<div class="line"><a name="l03340"></a><span class="lineno"> 3340</span>&#160; </div>
<div class="line"><a name="l03341"></a><span class="lineno"> 3341</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03342"></a><span class="lineno"> 3342</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03343"></a><span class="lineno"> 3343</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03344"></a><span class="lineno"> 3344</span>&#160; </div>
<div class="line"><a name="l03345"></a><span class="lineno"> 3345</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03346"></a><span class="lineno"> 3346</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03347"></a><span class="lineno"> 3347</span>&#160;<span class="preprocessor">    default  (none)              \</span></div>
<div class="line"><a name="l03348"></a><span class="lineno"> 3348</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal,stateVecImag, mask, chunkId,chunkSize ) \</span></div>
<div class="line"><a name="l03349"></a><span class="lineno"> 3349</span>&#160;<span class="preprocessor">    private  (index)</span></div>
<div class="line"><a name="l03350"></a><span class="lineno"> 3350</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03351"></a><span class="lineno"> 3351</span>&#160;    {</div>
<div class="line"><a name="l03352"></a><span class="lineno"> 3352</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03353"></a><span class="lineno"> 3353</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03354"></a><span class="lineno"> 3354</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03355"></a><span class="lineno"> 3355</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l03356"></a><span class="lineno"> 3356</span>&#160;            <span class="keywordflow">if</span> (mask == (mask &amp; (index+chunkId*chunkSize)) ){</div>
<div class="line"><a name="l03357"></a><span class="lineno"> 3357</span>&#160;                stateVecReal [index] = - stateVecReal [index];</div>
<div class="line"><a name="l03358"></a><span class="lineno"> 3358</span>&#160;                stateVecImag [index] = - stateVecImag [index];</div>
<div class="line"><a name="l03359"></a><span class="lineno"> 3359</span>&#160;            }</div>
<div class="line"><a name="l03360"></a><span class="lineno"> 3360</span>&#160;        }</div>
<div class="line"><a name="l03361"></a><span class="lineno"> 3361</span>&#160;    }</div>
<div class="line"><a name="l03362"></a><span class="lineno"> 3362</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__common_8c_source.html#l00044">getQubitBitMask()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00561">multiControlledPhaseFlip()</a>.</p>

</div>
</div>
<a id="aa662796ea6e0f471143c53becae8c12c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa662796ea6e0f471143c53becae8c12c">&#9670;&nbsp;</a></span>statevec_multiControlledPhaseShift()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledPhaseShift </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>controlQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numControlQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03059">3059</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03060"></a><span class="lineno"> 3060</span>&#160;{</div>
<div class="line"><a name="l03061"></a><span class="lineno"> 3061</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03062"></a><span class="lineno"> 3062</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l03063"></a><span class="lineno"> 3063</span>&#160; </div>
<div class="line"><a name="l03064"></a><span class="lineno"> 3064</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03065"></a><span class="lineno"> 3065</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l03066"></a><span class="lineno"> 3066</span>&#160; </div>
<div class="line"><a name="l03067"></a><span class="lineno"> 3067</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> mask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(controlQubits, numControlQubits);</div>
<div class="line"><a name="l03068"></a><span class="lineno"> 3068</span>&#160; </div>
<div class="line"><a name="l03069"></a><span class="lineno"> 3069</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03070"></a><span class="lineno"> 3070</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03071"></a><span class="lineno"> 3071</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03072"></a><span class="lineno"> 3072</span>&#160;    </div>
<div class="line"><a name="l03073"></a><span class="lineno"> 3073</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> stateRealLo, stateImagLo;</div>
<div class="line"><a name="l03074"></a><span class="lineno"> 3074</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> cosAngle = cos(angle);</div>
<div class="line"><a name="l03075"></a><span class="lineno"> 3075</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> sinAngle = sin(angle);</div>
<div class="line"><a name="l03076"></a><span class="lineno"> 3076</span>&#160; </div>
<div class="line"><a name="l03077"></a><span class="lineno"> 3077</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03078"></a><span class="lineno"> 3078</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03079"></a><span class="lineno"> 3079</span>&#160;<span class="preprocessor">    default  (none)              \</span></div>
<div class="line"><a name="l03080"></a><span class="lineno"> 3080</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal, stateVecImag, mask, chunkId,chunkSize,cosAngle,sinAngle) \</span></div>
<div class="line"><a name="l03081"></a><span class="lineno"> 3081</span>&#160;<span class="preprocessor">    private  (index, stateRealLo, stateImagLo)</span></div>
<div class="line"><a name="l03082"></a><span class="lineno"> 3082</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03083"></a><span class="lineno"> 3083</span>&#160;    {</div>
<div class="line"><a name="l03084"></a><span class="lineno"> 3084</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03085"></a><span class="lineno"> 3085</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03086"></a><span class="lineno"> 3086</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03087"></a><span class="lineno"> 3087</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l03088"></a><span class="lineno"> 3088</span>&#160;            <span class="keywordflow">if</span> (mask == (mask &amp; (index+chunkId*chunkSize)) ){</div>
<div class="line"><a name="l03089"></a><span class="lineno"> 3089</span>&#160;                </div>
<div class="line"><a name="l03090"></a><span class="lineno"> 3090</span>&#160;                stateRealLo = stateVecReal[index];</div>
<div class="line"><a name="l03091"></a><span class="lineno"> 3091</span>&#160;                stateImagLo = stateVecImag[index];</div>
<div class="line"><a name="l03092"></a><span class="lineno"> 3092</span>&#160;            </div>
<div class="line"><a name="l03093"></a><span class="lineno"> 3093</span>&#160;                stateVecReal[index] = cosAngle*stateRealLo - sinAngle*stateImagLo;</div>
<div class="line"><a name="l03094"></a><span class="lineno"> 3094</span>&#160;                stateVecImag[index] = sinAngle*stateRealLo + cosAngle*stateImagLo;  </div>
<div class="line"><a name="l03095"></a><span class="lineno"> 3095</span>&#160;            }</div>
<div class="line"><a name="l03096"></a><span class="lineno"> 3096</span>&#160;        }</div>
<div class="line"><a name="l03097"></a><span class="lineno"> 3097</span>&#160;    }</div>
<div class="line"><a name="l03098"></a><span class="lineno"> 3098</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__common_8c_source.html#l00044">getQubitBitMask()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00511">multiControlledPhaseShift()</a>.</p>

</div>
</div>
<a id="a3eadcb581f2623e21e4967f791d0439c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3eadcb581f2623e21e4967f791d0439c">&#9670;&nbsp;</a></span>statevec_multiControlledTwoQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledTwoQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>q1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>q2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct. </p>
<p>Note the order of q1 and q2 in the call to twoQubitUnitaryLocal is important.</p>
<p>@TODO: refactor so that the 'swap back' isn't performed; instead the qubit locations are updated. @TODO: the double swap (q1,q2 to 0,1) may be possible simultaneously by a bespoke swap routine. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">1381</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01381"></a><span class="lineno"> 1381</span>&#160;                                                                                                                    {</div>
<div class="line"><a name="l01382"></a><span class="lineno"> 1382</span>&#160;    <span class="keywordtype">int</span> q1FitsInNode = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, q1);</div>
<div class="line"><a name="l01383"></a><span class="lineno"> 1383</span>&#160;    <span class="keywordtype">int</span> q2FitsInNode = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, q2);</div>
<div class="line"><a name="l01384"></a><span class="lineno"> 1384</span>&#160;        </div>
<div class="line"><a name="l01385"></a><span class="lineno"> 1385</span>&#160;    <span class="keywordflow">if</span> (q1FitsInNode &amp;&amp; q2FitsInNode) {    </div>
<div class="line"><a name="l01386"></a><span class="lineno"> 1386</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, q1, q2, u);</div>
<div class="line"><a name="l01387"></a><span class="lineno"> 1387</span>&#160;        </div>
<div class="line"><a name="l01388"></a><span class="lineno"> 1388</span>&#160;    } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (q1FitsInNode) {</div>
<div class="line"><a name="l01389"></a><span class="lineno"> 1389</span>&#160;        <span class="keywordtype">int</span> qSwap = (q1 &gt; 0)? q1-1 : q1+1;</div>
<div class="line"><a name="l01390"></a><span class="lineno"> 1390</span>&#160; </div>
<div class="line"><a name="l01391"></a><span class="lineno"> 1391</span>&#160;        <span class="comment">// ensure ctrl == qSwap, ensure ctrlMask updates under the swap</span></div>
<div class="line"><a name="l01392"></a><span class="lineno"> 1392</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, qSwap))</div>
<div class="line"><a name="l01393"></a><span class="lineno"> 1393</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, q2), qSwap);</div>
<div class="line"><a name="l01394"></a><span class="lineno"> 1394</span>&#160; </div>
<div class="line"><a name="l01395"></a><span class="lineno"> 1395</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, qSwap);</div>
<div class="line"><a name="l01396"></a><span class="lineno"> 1396</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, q1, qSwap, u);</div>
<div class="line"><a name="l01397"></a><span class="lineno"> 1397</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, qSwap);</div>
<div class="line"><a name="l01398"></a><span class="lineno"> 1398</span>&#160; </div>
<div class="line"><a name="l01399"></a><span class="lineno"> 1399</span>&#160;    } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (q2FitsInNode) {</div>
<div class="line"><a name="l01400"></a><span class="lineno"> 1400</span>&#160;        <span class="keywordtype">int</span> qSwap = (q2 &gt; 0)? q2-1 : q2+1;</div>
<div class="line"><a name="l01401"></a><span class="lineno"> 1401</span>&#160;        </div>
<div class="line"><a name="l01402"></a><span class="lineno"> 1402</span>&#160;        <span class="comment">// ensure ctrl == qSwap, ensure ctrlMask updates under the swap</span></div>
<div class="line"><a name="l01403"></a><span class="lineno"> 1403</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, qSwap))</div>
<div class="line"><a name="l01404"></a><span class="lineno"> 1404</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, q1), qSwap);</div>
<div class="line"><a name="l01405"></a><span class="lineno"> 1405</span>&#160;        </div>
<div class="line"><a name="l01406"></a><span class="lineno"> 1406</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, qSwap);</div>
<div class="line"><a name="l01407"></a><span class="lineno"> 1407</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, qSwap, q2, u);</div>
<div class="line"><a name="l01408"></a><span class="lineno"> 1408</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, qSwap);</div>
<div class="line"><a name="l01409"></a><span class="lineno"> 1409</span>&#160;        </div>
<div class="line"><a name="l01410"></a><span class="lineno"> 1410</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01411"></a><span class="lineno"> 1411</span>&#160;        <span class="comment">// we know with certainty that both q1 and q2 &gt;= 2</span></div>
<div class="line"><a name="l01412"></a><span class="lineno"> 1412</span>&#160;        <span class="keywordtype">int</span> swap1 = 0;</div>
<div class="line"><a name="l01413"></a><span class="lineno"> 1413</span>&#160;        <span class="keywordtype">int</span> swap2 = 1;</div>
<div class="line"><a name="l01414"></a><span class="lineno"> 1414</span>&#160;        </div>
<div class="line"><a name="l01415"></a><span class="lineno"> 1415</span>&#160;        <span class="comment">// if ctrl == swap1 or swap2, ensure ctrlMask updates under the swap</span></div>
<div class="line"><a name="l01416"></a><span class="lineno"> 1416</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, swap1))</div>
<div class="line"><a name="l01417"></a><span class="lineno"> 1417</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, swap1), q1);</div>
<div class="line"><a name="l01418"></a><span class="lineno"> 1418</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, swap2))</div>
<div class="line"><a name="l01419"></a><span class="lineno"> 1419</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, swap2), q2);</div>
<div class="line"><a name="l01420"></a><span class="lineno"> 1420</span>&#160;        </div>
<div class="line"><a name="l01421"></a><span class="lineno"> 1421</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, swap1);</div>
<div class="line"><a name="l01422"></a><span class="lineno"> 1422</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, swap2);</div>
<div class="line"><a name="l01423"></a><span class="lineno"> 1423</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, swap1, swap2, u);</div>
<div class="line"><a name="l01424"></a><span class="lineno"> 1424</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, swap1);</div>
<div class="line"><a name="l01425"></a><span class="lineno"> 1425</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, swap2);</div>
<div class="line"><a name="l01426"></a><span class="lineno"> 1426</span>&#160;    }</div>
<div class="line"><a name="l01427"></a><span class="lineno"> 1427</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__internal_8h_source.html#l00034">maskContainsBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01747">statevec_multiControlledTwoQubitUnitaryLocal()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__common_8c_source.html#l00576">densmatr_applyKrausSuperoperator()</a>, <a class="el" href="QuEST_8c_source.html#l00283">multiControlledTwoQubitUnitary()</a>, <a class="el" href="QuEST__common_8c_source.html#l00523">statevec_controlledTwoQubitUnitary()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00517">statevec_twoQubitUnitary()</a>.</p>

</div>
</div>
<a id="a600bda10463e2078ce746ec28f2d39c9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a600bda10463e2078ce746ec28f2d39c9">&#9670;&nbsp;</a></span>statevec_multiControlledUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlQubitsMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlFlipMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">997</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00998"></a><span class="lineno">  998</span>&#160;{</div>
<div class="line"><a name="l00999"></a><span class="lineno">  999</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01000"></a><span class="lineno"> 1000</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01001"></a><span class="lineno"> 1001</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l01002"></a><span class="lineno"> 1002</span>&#160; </div>
<div class="line"><a name="l01003"></a><span class="lineno"> 1003</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01004"></a><span class="lineno"> 1004</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l01005"></a><span class="lineno"> 1005</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>&#160; </div>
<div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01008"></a><span class="lineno"> 1008</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab19f28e68330da68ea3caa2bdef32da9">statevec_multiControlledUnitaryLocal</a>(qureg, targetQubit, ctrlQubitsMask, ctrlFlipMask, u);</div>
<div class="line"><a name="l01010"></a><span class="lineno"> 1010</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01011"></a><span class="lineno"> 1011</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01012"></a><span class="lineno"> 1012</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a>(rankIsUpper, &amp;rot1, &amp;rot2, u);</div>
<div class="line"><a name="l01014"></a><span class="lineno"> 1014</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>&#160; </div>
<div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01017"></a><span class="lineno"> 1017</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>&#160; </div>
<div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to multiControlledUnitaryDistributed</span></div>
<div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01022"></a><span class="lineno"> 1022</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a>(qureg,targetQubit,ctrlQubitsMask,ctrlFlipMask,rot1,rot2,</div>
<div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01025"></a><span class="lineno"> 1025</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a>(qureg,targetQubit,ctrlQubitsMask,ctrlFlipMask,rot1,rot2,</div>
<div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01029"></a><span class="lineno"> 1029</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01030"></a><span class="lineno"> 1030</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l01031"></a><span class="lineno"> 1031</span>&#160;        }</div>
<div class="line"><a name="l01032"></a><span class="lineno"> 1032</span>&#160;    }</div>
<div class="line"><a name="l01033"></a><span class="lineno"> 1033</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02447">statevec_multiControlledUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02173">statevec_multiControlledUnitaryLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00374">multiControlledUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00389">multiStateControlledUnitary()</a>.</p>

</div>
</div>
<a id="a7a76950824f17e821415070a4bfdad5b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7a76950824f17e821415070a4bfdad5b">&#9670;&nbsp;</a></span>statevec_multiQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00529">529</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00529"></a><span class="lineno">  529</span>&#160;                                                                                             {</div>
<div class="line"><a name="l00530"></a><span class="lineno">  530</span>&#160;    </div>
<div class="line"><a name="l00531"></a><span class="lineno">  531</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> ctrlMask = 0;</div>
<div class="line"><a name="l00532"></a><span class="lineno">  532</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a>(qureg, ctrlMask, targets, numTargets, u);</div>
<div class="line"><a name="l00533"></a><span class="lineno">  533</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">statevec_multiControlledMultiQubitUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00863">applyMatrixN()</a>, and <a class="el" href="QuEST_8c_source.html#l00297">multiQubitUnitary()</a>.</p>

</div>
</div>
<a id="a2153d8611247dd3a2ef483355265cc99"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2153d8611247dd3a2ef483355265cc99">&#9670;&nbsp;</a></span>statevec_multiRotatePauli()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiRotatePauli </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targetQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>targetPaulis</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>applyConj</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>applyConj=1 will apply conjugate operation, else applyConj=0 </p>

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00411">411</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;  {</div>
<div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> fac = 1/sqrt(2);</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;    <a class="code" href="structComplex.html">Complex</a> uRxAlpha = {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = fac, .imag = 0}; <span class="comment">// Rx(pi/2)* rotates Z -&gt; Y</span></div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;    <a class="code" href="structComplex.html">Complex</a> uRxBeta = {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = 0, .imag = (applyConj)? fac : -fac};</div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;    <a class="code" href="structComplex.html">Complex</a> uRyAlpha = {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = fac, .imag = 0}; <span class="comment">// Ry(-pi/2) rotates Z -&gt; X</span></div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160;    <a class="code" href="structComplex.html">Complex</a> uRyBeta = {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = -fac, .imag = 0};</div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;    </div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;    <span class="comment">// mask may be modified to remove superfluous Identity ops</span></div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> mask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(targetQubits, numTargets);</div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;    </div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;    <span class="comment">// rotate basis so that exp(Z) will effect exp(Y) and exp(X)</span></div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t &lt; numTargets; t++) {</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;        <span class="keywordflow">if</span> (targetPaulis[t] == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a>)</div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;            mask -= 1LL &lt;&lt; targetQubits[t]; <span class="comment">// remove target from mask</span></div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;        <span class="keywordflow">if</span> (targetPaulis[t] == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>)</div>
<div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;            <a class="code" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a>(qureg, targetQubits[t], uRyAlpha, uRyBeta);</div>
<div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;        <span class="keywordflow">if</span> (targetPaulis[t] == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a>)</div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;            <a class="code" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a>(qureg, targetQubits[t], uRxAlpha, uRxBeta);</div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;        <span class="comment">// (targetPaulis[t] == 3) is Z basis</span></div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;    }</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;    </div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;    <span class="comment">// does nothing if there are no qubits to &#39;rotate&#39;</span></div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;    <span class="keywordflow">if</span> (mask != 0)</div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;        <a class="code" href="QuEST__internal_8h.html#a8d88b4ed94ab024e5e7b2f1f4f505b44">statevec_multiRotateZ</a>(qureg, mask, (applyConj)? -angle : angle);</div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;    </div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;    <span class="comment">// undo X and Y basis rotations</span></div>
<div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;    uRxBeta.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> *= -1;</div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;    uRyBeta.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> *= -1;</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t &lt; numTargets; t++) {</div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;        <span class="keywordflow">if</span> (targetPaulis[t] == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>)</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;            <a class="code" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a>(qureg, targetQubits[t], uRyAlpha, uRyBeta);</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;        <span class="keywordflow">if</span> (targetPaulis[t] == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a>)</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;            <a class="code" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a>(qureg, targetQubits[t], uRxAlpha, uRxBeta);</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    }</div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00044">getQubitBitMask()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00096">PAULI_I</a>, <a class="el" href="QuEST_8h_source.html#l00096">PAULI_X</a>, <a class="el" href="QuEST_8h_source.html#l00096">PAULI_Y</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03109">statevec_multiRotateZ()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__common_8c_source.html#l00698">applyExponentiatedPauliHamil()</a>, and <a class="el" href="QuEST_8c_source.html#l00642">multiRotatePauli()</a>.</p>

</div>
</div>
<a id="a8d88b4ed94ab024e5e7b2f1f4f505b44"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8d88b4ed94ab024e5e7b2f1f4f505b44">&#9670;&nbsp;</a></span>statevec_multiRotateZ()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiRotateZ </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>mask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03109">3109</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03110"></a><span class="lineno"> 3110</span>&#160;{</div>
<div class="line"><a name="l03111"></a><span class="lineno"> 3111</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03112"></a><span class="lineno"> 3112</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l03113"></a><span class="lineno"> 3113</span>&#160; </div>
<div class="line"><a name="l03114"></a><span class="lineno"> 3114</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03115"></a><span class="lineno"> 3115</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l03116"></a><span class="lineno"> 3116</span>&#160; </div>
<div class="line"><a name="l03117"></a><span class="lineno"> 3117</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03118"></a><span class="lineno"> 3118</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03119"></a><span class="lineno"> 3119</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03120"></a><span class="lineno"> 3120</span>&#160;    </div>
<div class="line"><a name="l03121"></a><span class="lineno"> 3121</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> stateReal, stateImag;</div>
<div class="line"><a name="l03122"></a><span class="lineno"> 3122</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> cosAngle = cos(angle/2.0);</div>
<div class="line"><a name="l03123"></a><span class="lineno"> 3123</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> sinAngle = sin(angle/2.0); </div>
<div class="line"><a name="l03124"></a><span class="lineno"> 3124</span>&#160;    </div>
<div class="line"><a name="l03125"></a><span class="lineno"> 3125</span>&#160;    <span class="comment">// = +-1, to flip sinAngle based on target qubit parity, to effect</span></div>
<div class="line"><a name="l03126"></a><span class="lineno"> 3126</span>&#160;    <span class="comment">// exp(-angle/2 i fac_j)|j&gt;</span></div>
<div class="line"><a name="l03127"></a><span class="lineno"> 3127</span>&#160;    <span class="keywordtype">int</span> fac; </div>
<div class="line"><a name="l03128"></a><span class="lineno"> 3128</span>&#160; </div>
<div class="line"><a name="l03129"></a><span class="lineno"> 3129</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03130"></a><span class="lineno"> 3130</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03131"></a><span class="lineno"> 3131</span>&#160;<span class="preprocessor">    default  (none)              \</span></div>
<div class="line"><a name="l03132"></a><span class="lineno"> 3132</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal, stateVecImag, mask, chunkId,chunkSize,cosAngle,sinAngle) \</span></div>
<div class="line"><a name="l03133"></a><span class="lineno"> 3133</span>&#160;<span class="preprocessor">    private  (index, fac, stateReal, stateImag)</span></div>
<div class="line"><a name="l03134"></a><span class="lineno"> 3134</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03135"></a><span class="lineno"> 3135</span>&#160;    {</div>
<div class="line"><a name="l03136"></a><span class="lineno"> 3136</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03137"></a><span class="lineno"> 3137</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l03138"></a><span class="lineno"> 3138</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03139"></a><span class="lineno"> 3139</span>&#160;        <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l03140"></a><span class="lineno"> 3140</span>&#160;            stateReal = stateVecReal[index];</div>
<div class="line"><a name="l03141"></a><span class="lineno"> 3141</span>&#160;            stateImag = stateVecImag[index];</div>
<div class="line"><a name="l03142"></a><span class="lineno"> 3142</span>&#160;            </div>
<div class="line"><a name="l03143"></a><span class="lineno"> 3143</span>&#160;            <span class="comment">// odd-parity target qubits get fac_j = -1</span></div>
<div class="line"><a name="l03144"></a><span class="lineno"> 3144</span>&#160;            fac = <a class="code" href="QuEST__cpu_8c.html#a37e522505286f17fe6ef74b9f607a5c6">getBitMaskParity</a>(mask &amp; (index+chunkId*chunkSize))? -1 : 1;</div>
<div class="line"><a name="l03145"></a><span class="lineno"> 3145</span>&#160;            stateVecReal[index] = cosAngle*stateReal + fac * sinAngle*stateImag;</div>
<div class="line"><a name="l03146"></a><span class="lineno"> 3146</span>&#160;            stateVecImag[index] = - fac * sinAngle*stateReal + cosAngle*stateImag;  </div>
<div class="line"><a name="l03147"></a><span class="lineno"> 3147</span>&#160;        }</div>
<div class="line"><a name="l03148"></a><span class="lineno"> 3148</span>&#160;    }</div>
<div class="line"><a name="l03149"></a><span class="lineno"> 3149</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03100">getBitMaskParity()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00626">multiRotateZ()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00411">statevec_multiRotatePauli()</a>.</p>

</div>
</div>
<a id="a1c82b5e914a8a39c5c7b782dbc16fa76"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1c82b5e914a8a39c5c7b782dbc16fa76">&#9670;&nbsp;</a></span>statevec_pauliX()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliX </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01034">1034</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>&#160;{</div>
<div class="line"><a name="l01036"></a><span class="lineno"> 1036</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01037"></a><span class="lineno"> 1037</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01038"></a><span class="lineno"> 1038</span>&#160; </div>
<div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l01041"></a><span class="lineno"> 1041</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>&#160; </div>
<div class="line"><a name="l01043"></a><span class="lineno"> 1043</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01044"></a><span class="lineno"> 1044</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01045"></a><span class="lineno"> 1045</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#aa987d1e0ba97da2ca540194356dd62de">statevec_pauliXLocal</a>(qureg, targetQubit);</div>
<div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01053"></a><span class="lineno"> 1053</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. pauliX just replaces</span></div>
<div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>&#160;        <span class="comment">// this rank&#39;s values with pair values</span></div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a464efbd1d7ca5a7b25c83ada001955c2">statevec_pauliXDistributed</a>(qureg,</div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>&#160;                qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">// in</span></div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">// out</span></div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>&#160;    }</div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02556">statevec_pauliXDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02498">statevec_pauliXLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00433">pauliX()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00451">statevec_applyPauliProd()</a>.</p>

</div>
</div>
<a id="af1cca787f3b0e0c91ffb2495f9ad8d5a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af1cca787f3b0e0c91ffb2495f9ad8d5a">&#9670;&nbsp;</a></span>statevec_pauliY()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliY </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01090">1090</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01091"></a><span class="lineno"> 1091</span>&#160;{       </div>
<div class="line"><a name="l01092"></a><span class="lineno"> 1092</span>&#160;        <span class="keywordtype">int</span> conjFac = 1;</div>
<div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>&#160; </div>
<div class="line"><a name="l01094"></a><span class="lineno"> 1094</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01095"></a><span class="lineno"> 1095</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01096"></a><span class="lineno"> 1096</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01097"></a><span class="lineno"> 1097</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01098"></a><span class="lineno"> 1098</span>&#160; </div>
<div class="line"><a name="l01099"></a><span class="lineno"> 1099</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01100"></a><span class="lineno"> 1100</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a>(qureg, targetQubit, conjFac);</div>
<div class="line"><a name="l01101"></a><span class="lineno"> 1101</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01102"></a><span class="lineno"> 1102</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01103"></a><span class="lineno"> 1103</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01104"></a><span class="lineno"> 1104</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01105"></a><span class="lineno"> 1105</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01106"></a><span class="lineno"> 1106</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01107"></a><span class="lineno"> 1107</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01108"></a><span class="lineno"> 1108</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a>(qureg,</div>
<div class="line"><a name="l01109"></a><span class="lineno"> 1109</span>&#160;                qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">// in</span></div>
<div class="line"><a name="l01110"></a><span class="lineno"> 1110</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">// out</span></div>
<div class="line"><a name="l01111"></a><span class="lineno"> 1111</span>&#160;                rankIsUpper, conjFac);</div>
<div class="line"><a name="l01112"></a><span class="lineno"> 1112</span>&#160;    }</div>
<div class="line"><a name="l01113"></a><span class="lineno"> 1113</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02739">statevec_pauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02682">statevec_pauliYLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00444">pauliY()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00451">statevec_applyPauliProd()</a>.</p>

</div>
</div>
<a id="a81fbd2eccd0d0e5a3cece4df2f96cb92"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a81fbd2eccd0d0e5a3cece4df2f96cb92">&#9670;&nbsp;</a></span>statevec_pauliYConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliYConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01115">1115</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01116"></a><span class="lineno"> 1116</span>&#160;{       </div>
<div class="line"><a name="l01117"></a><span class="lineno"> 1117</span>&#160;        <span class="keywordtype">int</span> conjFac = -1;</div>
<div class="line"><a name="l01118"></a><span class="lineno"> 1118</span>&#160; </div>
<div class="line"><a name="l01119"></a><span class="lineno"> 1119</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01122"></a><span class="lineno"> 1122</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>&#160; </div>
<div class="line"><a name="l01124"></a><span class="lineno"> 1124</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01125"></a><span class="lineno"> 1125</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a>(qureg, targetQubit, conjFac);</div>
<div class="line"><a name="l01126"></a><span class="lineno"> 1126</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01128"></a><span class="lineno"> 1128</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01133"></a><span class="lineno"> 1133</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a>(qureg,</div>
<div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>&#160;                qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">// in</span></div>
<div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">// out</span></div>
<div class="line"><a name="l01136"></a><span class="lineno"> 1136</span>&#160;                rankIsUpper, conjFac);</div>
<div class="line"><a name="l01137"></a><span class="lineno"> 1137</span>&#160;    }</div>
<div class="line"><a name="l01138"></a><span class="lineno"> 1138</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02739">statevec_pauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02682">statevec_pauliYLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00444">pauliY()</a>.</p>

</div>
</div>
<a id="ab14df201e5c05527dc77cfeb6f583042"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab14df201e5c05527dc77cfeb6f583042">&#9670;&nbsp;</a></span>statevec_pauliZ()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliZ </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00258">258</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;                                                   {</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    <a class="code" href="structComplex.html">Complex</a> term; </div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = -1;</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> =  0;</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a>(qureg, targetQubit, term);</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02978">statevec_phaseShiftByTerm()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00455">pauliZ()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00451">statevec_applyPauliProd()</a>.</p>

</div>
</div>
<a id="a5ef139196852f92fe8271c82964eadff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5ef139196852f92fe8271c82964eadff">&#9670;&nbsp;</a></span>statevec_phaseShift()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_phaseShift </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00251">251</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;                                                                    {</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;    <a class="code" href="structComplex.html">Complex</a> term; </div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;    term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = cos(angle); </div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;    term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = sin(angle);</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a>(qureg, targetQubit, term);</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02978">statevec_phaseShiftByTerm()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00488">phaseShift()</a>.</p>

</div>
</div>
<a id="a535cc3c9962d511078691e4d64b4e272"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a535cc3c9962d511078691e4d64b4e272">&#9670;&nbsp;</a></span>statevec_phaseShiftByTerm()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_phaseShiftByTerm </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>term</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l02978">2978</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l02979"></a><span class="lineno"> 2979</span>&#160;{       </div>
<div class="line"><a name="l02980"></a><span class="lineno"> 2980</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l02981"></a><span class="lineno"> 2981</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> stateVecSize;</div>
<div class="line"><a name="l02982"></a><span class="lineno"> 2982</span>&#160;    <span class="keywordtype">int</span> targetBit;</div>
<div class="line"><a name="l02983"></a><span class="lineno"> 2983</span>&#160;    </div>
<div class="line"><a name="l02984"></a><span class="lineno"> 2984</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkSize=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l02985"></a><span class="lineno"> 2985</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkId=qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l02986"></a><span class="lineno"> 2986</span>&#160; </div>
<div class="line"><a name="l02987"></a><span class="lineno"> 2987</span>&#160;    <span class="comment">// dimension of the state vector</span></div>
<div class="line"><a name="l02988"></a><span class="lineno"> 2988</span>&#160;    stateVecSize = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l02989"></a><span class="lineno"> 2989</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecReal = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l02990"></a><span class="lineno"> 2990</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *stateVecImag = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l02991"></a><span class="lineno"> 2991</span>&#160;    </div>
<div class="line"><a name="l02992"></a><span class="lineno"> 2992</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> stateRealLo, stateImagLo;</div>
<div class="line"><a name="l02993"></a><span class="lineno"> 2993</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> cosAngle = term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l02994"></a><span class="lineno"> 2994</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> sinAngle = term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l02995"></a><span class="lineno"> 2995</span>&#160; </div>
<div class="line"><a name="l02996"></a><span class="lineno"> 2996</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l02997"></a><span class="lineno"> 2997</span>&#160;<span class="preprocessor"># pragma omp parallel for \</span></div>
<div class="line"><a name="l02998"></a><span class="lineno"> 2998</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l02999"></a><span class="lineno"> 2999</span>&#160;<span class="preprocessor">    shared   (stateVecSize, stateVecReal,stateVecImag, cosAngle,sinAngle, \</span></div>
<div class="line"><a name="l03000"></a><span class="lineno"> 3000</span>&#160;<span class="preprocessor">                chunkId,chunkSize,targetQubit) \</span></div>
<div class="line"><a name="l03001"></a><span class="lineno"> 3001</span>&#160;<span class="preprocessor">    private  (index,targetBit,stateRealLo,stateImagLo) \</span></div>
<div class="line"><a name="l03002"></a><span class="lineno"> 3002</span>&#160;<span class="preprocessor">    schedule (static)</span></div>
<div class="line"><a name="l03003"></a><span class="lineno"> 3003</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03004"></a><span class="lineno"> 3004</span>&#160;    <span class="keywordflow">for</span> (index=0; index&lt;stateVecSize; index++) {</div>
<div class="line"><a name="l03005"></a><span class="lineno"> 3005</span>&#160;        </div>
<div class="line"><a name="l03006"></a><span class="lineno"> 3006</span>&#160;        <span class="comment">// update the coeff of the |1&gt; state of the target qubit</span></div>
<div class="line"><a name="l03007"></a><span class="lineno"> 3007</span>&#160;        targetBit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a> (targetQubit, index+chunkId*chunkSize);</div>
<div class="line"><a name="l03008"></a><span class="lineno"> 3008</span>&#160;        <span class="keywordflow">if</span> (targetBit) {</div>
<div class="line"><a name="l03009"></a><span class="lineno"> 3009</span>&#160;            </div>
<div class="line"><a name="l03010"></a><span class="lineno"> 3010</span>&#160;            stateRealLo = stateVecReal[index];</div>
<div class="line"><a name="l03011"></a><span class="lineno"> 3011</span>&#160;            stateImagLo = stateVecImag[index];</div>
<div class="line"><a name="l03012"></a><span class="lineno"> 3012</span>&#160;            </div>
<div class="line"><a name="l03013"></a><span class="lineno"> 3013</span>&#160;            stateVecReal[index] = cosAngle*stateRealLo - sinAngle*stateImagLo;</div>
<div class="line"><a name="l03014"></a><span class="lineno"> 3014</span>&#160;            stateVecImag[index] = sinAngle*stateRealLo + cosAngle*stateImagLo;  </div>
<div class="line"><a name="l03015"></a><span class="lineno"> 3015</span>&#160;        }</div>
<div class="line"><a name="l03016"></a><span class="lineno"> 3016</span>&#160;    }</div>
<div class="line"><a name="l03017"></a><span class="lineno"> 3017</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__common_8c_source.html#l00258">statevec_pauliZ()</a>, <a class="el" href="QuEST__common_8c_source.html#l00251">statevec_phaseShift()</a>, <a class="el" href="QuEST__common_8c_source.html#l00265">statevec_sGate()</a>, <a class="el" href="QuEST__common_8c_source.html#l00279">statevec_sGateConj()</a>, <a class="el" href="QuEST__common_8c_source.html#l00272">statevec_tGate()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00286">statevec_tGateConj()</a>.</p>

</div>
</div>
<a id="a1e57230c7995447039e62a84c0a36524"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1e57230c7995447039e62a84c0a36524">&#9670;&nbsp;</a></span>statevec_reportStateToScreen()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_reportStateToScreen </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td>
          <td class="paramname"><em>env</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>reportRank</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Print the current state vector of probability amplitudes for a set of qubits to standard out. </p>
<p>For debugging purposes. Each rank should print output serially. Only print output for systems &lt;= 5 qubits </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01366">1366</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01366"></a><span class="lineno"> 1366</span>&#160;                                                                            {</div>
<div class="line"><a name="l01367"></a><span class="lineno"> 1367</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01368"></a><span class="lineno"> 1368</span>&#160;    <span class="keywordtype">int</span> rank;</div>
<div class="line"><a name="l01369"></a><span class="lineno"> 1369</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>&lt;=5){</div>
<div class="line"><a name="l01370"></a><span class="lineno"> 1370</span>&#160;        <span class="keywordflow">for</span> (rank=0; rank&lt;qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>; rank++){</div>
<div class="line"><a name="l01371"></a><span class="lineno"> 1371</span>&#160;            <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==rank){</div>
<div class="line"><a name="l01372"></a><span class="lineno"> 1372</span>&#160;                <span class="keywordflow">if</span> (reportRank) {</div>
<div class="line"><a name="l01373"></a><span class="lineno"> 1373</span>&#160;                    printf(<span class="stringliteral">&quot;Reporting state from rank %d [\n&quot;</span>, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>);</div>
<div class="line"><a name="l01374"></a><span class="lineno"> 1374</span>&#160;                    printf(<span class="stringliteral">&quot;real, imag\n&quot;</span>);</div>
<div class="line"><a name="l01375"></a><span class="lineno"> 1375</span>&#160;                } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (rank==0) {</div>
<div class="line"><a name="l01376"></a><span class="lineno"> 1376</span>&#160;                    printf(<span class="stringliteral">&quot;Reporting state [\n&quot;</span>);</div>
<div class="line"><a name="l01377"></a><span class="lineno"> 1377</span>&#160;                    printf(<span class="stringliteral">&quot;real, imag\n&quot;</span>);</div>
<div class="line"><a name="l01378"></a><span class="lineno"> 1378</span>&#160;                }</div>
<div class="line"><a name="l01379"></a><span class="lineno"> 1379</span>&#160; </div>
<div class="line"><a name="l01380"></a><span class="lineno"> 1380</span>&#160;                <span class="keywordflow">for</span>(index=0; index&lt;qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; index++){</div>
<div class="line"><a name="l01381"></a><span class="lineno"> 1381</span>&#160;                    <span class="comment">//printf(REAL_STRING_FORMAT &quot;, &quot; REAL_STRING_FORMAT &quot;\n&quot;, qureg.pairStateVec.real[index], qureg.pairStateVec.imag[index]);</span></div>
<div class="line"><a name="l01382"></a><span class="lineno"> 1382</span>&#160;                    printf(REAL_STRING_FORMAT <span class="stringliteral">&quot;, &quot;</span> REAL_STRING_FORMAT <span class="stringliteral">&quot;\n&quot;</span>, qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index], qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]);</div>
<div class="line"><a name="l01383"></a><span class="lineno"> 1383</span>&#160;                }</div>
<div class="line"><a name="l01384"></a><span class="lineno"> 1384</span>&#160;                <span class="keywordflow">if</span> (reportRank || rank==qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>-1) printf(<span class="stringliteral">&quot;]\n&quot;</span>);</div>
<div class="line"><a name="l01385"></a><span class="lineno"> 1385</span>&#160;            }</div>
<div class="line"><a name="l01386"></a><span class="lineno"> 1386</span>&#160;            <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(env);</div>
<div class="line"><a name="l01387"></a><span class="lineno"> 1387</span>&#160;        }</div>
<div class="line"><a name="l01388"></a><span class="lineno"> 1388</span>&#160;    } <span class="keywordflow">else</span> printf(<span class="stringliteral">&quot;Error: reportStateToScreen will not print output for systems of more than 5 qubits.\n&quot;</span>);</div>
<div class="line"><a name="l01389"></a><span class="lineno"> 1389</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00461">copyStateFromGPU()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00210">Qureg::numQubitsInStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01324">reportStateToScreen()</a>.</p>

</div>
</div>
<a id="adf5fbea75826cde7d86fd7c31bcf3dec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adf5fbea75826cde7d86fd7c31bcf3dec">&#9670;&nbsp;</a></span>statevec_rotateAroundAxis()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_rotateAroundAxis </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>rotQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a>&#160;</td>
          <td class="paramname"><em>axis</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00311">311</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;                                                                                   {</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160; </div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;    <a class="code" href="structComplex.html">Complex</a> alpha, beta;</div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;    <a class="code" href="QuEST__common_8c.html#a71b3ae4402c1c5039d3086ca0e47a522">getComplexPairFromRotation</a>(angle, axis, &amp;alpha, &amp;beta);</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;    <a class="code" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a>(qureg, rotQubit, alpha, beta);</div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00114">getComplexPairFromRotation()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00575">rotateAroundAxis()</a>, <a class="el" href="QuEST__common_8c_source.html#l00293">statevec_rotateX()</a>, <a class="el" href="QuEST__common_8c_source.html#l00299">statevec_rotateY()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00305">statevec_rotateZ()</a>.</p>

</div>
</div>
<a id="a2cbfe9f416d4d8acb56213841f62cb53"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2cbfe9f416d4d8acb56213841f62cb53">&#9670;&nbsp;</a></span>statevec_rotateAroundAxisConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_rotateAroundAxisConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>rotQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVector.html">Vector</a>&#160;</td>
          <td class="paramname"><em>axis</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00318">318</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;                                                                                       {</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160; </div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;    <a class="code" href="structComplex.html">Complex</a> alpha, beta;</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;    <a class="code" href="QuEST__common_8c.html#a71b3ae4402c1c5039d3086ca0e47a522">getComplexPairFromRotation</a>(angle, axis, &amp;alpha, &amp;beta);</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;    alpha.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> *= -1; </div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;    beta.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> *= -1;</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;    <a class="code" href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a>(qureg, rotQubit, alpha, beta);</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00114">getComplexPairFromRotation()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00575">rotateAroundAxis()</a>.</p>

</div>
</div>
<a id="ab8687e6ea5cf35503c223051837f3b94"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab8687e6ea5cf35503c223051837f3b94">&#9670;&nbsp;</a></span>statevec_rotateX()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_rotateX </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>rotQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00293">293</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;                                                             {</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160; </div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = {1, 0, 0};</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;    <a class="code" href="QuEST__common_8c.html#adf5fbea75826cde7d86fd7c31bcf3dec">statevec_rotateAroundAxis</a>(qureg, rotQubit, angle, unitAxis);</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00311">statevec_rotateAroundAxis()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00188">rotateX()</a>.</p>

</div>
</div>
<a id="a1f0db2800d13b6c2b120e05129cd13cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1f0db2800d13b6c2b120e05129cd13cb">&#9670;&nbsp;</a></span>statevec_rotateY()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_rotateY </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>rotQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00299">299</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;                                                             {</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160; </div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = {0, 1, 0};</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;    <a class="code" href="QuEST__common_8c.html#adf5fbea75826cde7d86fd7c31bcf3dec">statevec_rotateAroundAxis</a>(qureg, rotQubit, angle, unitAxis);</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00311">statevec_rotateAroundAxis()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00199">rotateY()</a>.</p>

</div>
</div>
<a id="a2b2b8c69566a49cdf4a3fa2cb4f5e03c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2b2b8c69566a49cdf4a3fa2cb4f5e03c">&#9670;&nbsp;</a></span>statevec_rotateZ()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_rotateZ </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>rotQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00305">305</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;                                                             {</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160; </div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;    <a class="code" href="structVector.html">Vector</a> unitAxis = {0, 0, 1};</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;    <a class="code" href="QuEST__common_8c.html#adf5fbea75826cde7d86fd7c31bcf3dec">statevec_rotateAroundAxis</a>(qureg, rotQubit, angle, unitAxis);</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00311">statevec_rotateAroundAxis()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00210">rotateZ()</a>.</p>

</div>
</div>
<a id="aa121d55f2ca09c06a96ddcd433c60b0f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa121d55f2ca09c06a96ddcd433c60b0f">&#9670;&nbsp;</a></span>statevec_setAmps()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_setAmps </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>startInd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>reals</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>imags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>numAmps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l01237">1237</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01237"></a><span class="lineno"> 1237</span>&#160;                                                                                                              {</div>
<div class="line"><a name="l01238"></a><span class="lineno"> 1238</span>&#160;    </div>
<div class="line"><a name="l01239"></a><span class="lineno"> 1239</span>&#160;    <span class="comment">/* this is actually distributed, since the user&#39;s code runs on every node */</span></div>
<div class="line"><a name="l01240"></a><span class="lineno"> 1240</span>&#160;    </div>
<div class="line"><a name="l01241"></a><span class="lineno"> 1241</span>&#160;    <span class="comment">// local start/end indices of the given amplitudes, assuming they fit in this chunk</span></div>
<div class="line"><a name="l01242"></a><span class="lineno"> 1242</span>&#160;    <span class="comment">// these may be negative or above qureg.numAmpsPerChunk</span></div>
<div class="line"><a name="l01243"></a><span class="lineno"> 1243</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localStartInd = startInd - qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01244"></a><span class="lineno"> 1244</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localEndInd = localStartInd + numAmps; <span class="comment">// exclusive</span></div>
<div class="line"><a name="l01245"></a><span class="lineno"> 1245</span>&#160;    </div>
<div class="line"><a name="l01246"></a><span class="lineno"> 1246</span>&#160;    <span class="comment">// add this to a local index to get corresponding elem in reals &amp; imags</span></div>
<div class="line"><a name="l01247"></a><span class="lineno"> 1247</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> offset = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> - startInd;</div>
<div class="line"><a name="l01248"></a><span class="lineno"> 1248</span>&#160;    </div>
<div class="line"><a name="l01249"></a><span class="lineno"> 1249</span>&#160;    <span class="comment">// restrict these indices to fit into this chunk</span></div>
<div class="line"><a name="l01250"></a><span class="lineno"> 1250</span>&#160;    <span class="keywordflow">if</span> (localStartInd &lt; 0)</div>
<div class="line"><a name="l01251"></a><span class="lineno"> 1251</span>&#160;        localStartInd = 0;</div>
<div class="line"><a name="l01252"></a><span class="lineno"> 1252</span>&#160;    <span class="keywordflow">if</span> (localEndInd &gt; qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>)</div>
<div class="line"><a name="l01253"></a><span class="lineno"> 1253</span>&#160;        localEndInd = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01254"></a><span class="lineno"> 1254</span>&#160;    <span class="comment">// they may now be out of order = no iterations</span></div>
<div class="line"><a name="l01255"></a><span class="lineno"> 1255</span>&#160;    </div>
<div class="line"><a name="l01256"></a><span class="lineno"> 1256</span>&#160;    <span class="comment">// unpacking OpenMP vars</span></div>
<div class="line"><a name="l01257"></a><span class="lineno"> 1257</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l01258"></a><span class="lineno"> 1258</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l01259"></a><span class="lineno"> 1259</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* vecIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l01260"></a><span class="lineno"> 1260</span>&#160;    </div>
<div class="line"><a name="l01261"></a><span class="lineno"> 1261</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01262"></a><span class="lineno"> 1262</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l01263"></a><span class="lineno"> 1263</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l01264"></a><span class="lineno"> 1264</span>&#160;<span class="preprocessor">    shared   (localStartInd,localEndInd, vecRe,vecIm, reals,imags, offset) \</span></div>
<div class="line"><a name="l01265"></a><span class="lineno"> 1265</span>&#160;<span class="preprocessor">    private  (index) </span></div>
<div class="line"><a name="l01266"></a><span class="lineno"> 1266</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01267"></a><span class="lineno"> 1267</span>&#160;    {</div>
<div class="line"><a name="l01268"></a><span class="lineno"> 1268</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l01269"></a><span class="lineno"> 1269</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l01270"></a><span class="lineno"> 1270</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l01271"></a><span class="lineno"> 1271</span>&#160;        <span class="comment">// iterate these local inds - this might involve no iterations</span></div>
<div class="line"><a name="l01272"></a><span class="lineno"> 1272</span>&#160;        <span class="keywordflow">for</span> (index=localStartInd; index &lt; localEndInd; index++) {</div>
<div class="line"><a name="l01273"></a><span class="lineno"> 1273</span>&#160;            vecRe[index] = reals[index + offset];</div>
<div class="line"><a name="l01274"></a><span class="lineno"> 1274</span>&#160;            vecIm[index] = imags[index + offset];</div>
<div class="line"><a name="l01275"></a><span class="lineno"> 1275</span>&#160;        }</div>
<div class="line"><a name="l01276"></a><span class="lineno"> 1276</span>&#160;    }</div>
<div class="line"><a name="l01277"></a><span class="lineno"> 1277</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00227">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00157">initStateFromAmps()</a>, <a class="el" href="QuEST_8c_source.html#l00781">setAmps()</a>, and <a class="el" href="QuEST_8c_source.html#l00790">setDensityAmps()</a>.</p>

</div>
</div>
<a id="ad64a23933361fafc1b6b1787759c2663"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad64a23933361fafc1b6b1787759c2663">&#9670;&nbsp;</a></span>statevec_setWeightedQureg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_setWeightedQureg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>fac1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>fac2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>facOut</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l03619">3619</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l03619"></a><span class="lineno"> 3619</span>&#160;                                                                                                                  {</div>
<div class="line"><a name="l03620"></a><span class="lineno"> 3620</span>&#160; </div>
<div class="line"><a name="l03621"></a><span class="lineno"> 3621</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = qureg1.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l03622"></a><span class="lineno"> 3622</span>&#160; </div>
<div class="line"><a name="l03623"></a><span class="lineno"> 3623</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecRe1 = qureg1.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03624"></a><span class="lineno"> 3624</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecIm1 = qureg1.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03625"></a><span class="lineno"> 3625</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecRe2 = qureg2.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03626"></a><span class="lineno"> 3626</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecIm2 = qureg2.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03627"></a><span class="lineno"> 3627</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecReOut = out.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l03628"></a><span class="lineno"> 3628</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *vecImOut = out.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l03629"></a><span class="lineno"> 3629</span>&#160; </div>
<div class="line"><a name="l03630"></a><span class="lineno"> 3630</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facRe1 = fac1.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>; </div>
<div class="line"><a name="l03631"></a><span class="lineno"> 3631</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facIm1 = fac1.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l03632"></a><span class="lineno"> 3632</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facRe2 = fac2.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l03633"></a><span class="lineno"> 3633</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facIm2 = fac2.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l03634"></a><span class="lineno"> 3634</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facReOut = facOut.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l03635"></a><span class="lineno"> 3635</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> facImOut = facOut.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l03636"></a><span class="lineno"> 3636</span>&#160; </div>
<div class="line"><a name="l03637"></a><span class="lineno"> 3637</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> re1,im1, re2,im2, reOut,imOut;</div>
<div class="line"><a name="l03638"></a><span class="lineno"> 3638</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l03639"></a><span class="lineno"> 3639</span>&#160; </div>
<div class="line"><a name="l03640"></a><span class="lineno"> 3640</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03641"></a><span class="lineno"> 3641</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l03642"></a><span class="lineno"> 3642</span>&#160;<span class="preprocessor">    shared    (vecRe1,vecIm1, vecRe2,vecIm2, vecReOut,vecImOut, facRe1,facIm1,facRe2,facIm2, numAmps) \</span></div>
<div class="line"><a name="l03643"></a><span class="lineno"> 3643</span>&#160;<span class="preprocessor">    private   (index, re1,im1, re2,im2, reOut,imOut)</span></div>
<div class="line"><a name="l03644"></a><span class="lineno"> 3644</span>&#160;<span class="preprocessor"># endif </span></div>
<div class="line"><a name="l03645"></a><span class="lineno"> 3645</span>&#160;    {</div>
<div class="line"><a name="l03646"></a><span class="lineno"> 3646</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l03647"></a><span class="lineno"> 3647</span>&#160;<span class="preprocessor"># pragma omp for schedule  (static)</span></div>
<div class="line"><a name="l03648"></a><span class="lineno"> 3648</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l03649"></a><span class="lineno"> 3649</span>&#160;        <span class="keywordflow">for</span> (index=0LL; index&lt;numAmps; index++) {</div>
<div class="line"><a name="l03650"></a><span class="lineno"> 3650</span>&#160;            re1 = vecRe1[index]; im1 = vecIm1[index];</div>
<div class="line"><a name="l03651"></a><span class="lineno"> 3651</span>&#160;            re2 = vecRe2[index]; im2 = vecIm2[index];</div>
<div class="line"><a name="l03652"></a><span class="lineno"> 3652</span>&#160;            reOut = vecReOut[index];</div>
<div class="line"><a name="l03653"></a><span class="lineno"> 3653</span>&#160;            imOut = vecImOut[index];</div>
<div class="line"><a name="l03654"></a><span class="lineno"> 3654</span>&#160; </div>
<div class="line"><a name="l03655"></a><span class="lineno"> 3655</span>&#160;            vecReOut[index] = (facReOut*reOut - facImOut*imOut) + (facRe1*re1 - facIm1*im1) + (facRe2*re2 - facIm2*im2);</div>
<div class="line"><a name="l03656"></a><span class="lineno"> 3656</span>&#160;            vecImOut[index] = (facReOut*imOut + facImOut*reOut) + (facRe1*im1 + facIm1*re1) + (facRe2*im2 + facIm2*re2);</div>
<div class="line"><a name="l03657"></a><span class="lineno"> 3657</span>&#160;        }</div>
<div class="line"><a name="l03658"></a><span class="lineno"> 3658</span>&#160;    }</div>
<div class="line"><a name="l03659"></a><span class="lineno"> 3659</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00797">setWeightedQureg()</a>, and <a class="el" href="QuEST__common_8c_source.html#l00494">statevec_applyPauliSum()</a>.</p>

</div>
</div>
<a id="a559d175d31cec552fc09aec3e8a78d11"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a559d175d31cec552fc09aec3e8a78d11">&#9670;&nbsp;</a></span>statevec_sGate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_sGate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00265">265</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;                                                  {</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;    <a class="code" href="structComplex.html">Complex</a> term; </div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;    term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = 0;</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;    term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = 1;</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a>(qureg, targetQubit, term);</div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;} </div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02978">statevec_phaseShiftByTerm()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00466">sGate()</a>.</p>

</div>
</div>
<a id="a142b424d903dfaca7a7ac166076f543a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a142b424d903dfaca7a7ac166076f543a">&#9670;&nbsp;</a></span>statevec_sGateConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_sGateConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00279">279</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;                                                      {</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;    <a class="code" href="structComplex.html">Complex</a> term; </div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;    term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> =  0;</div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;    term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = -1;</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a>(qureg, targetQubit, term);</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;} </div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02978">statevec_phaseShiftByTerm()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00466">sGate()</a>.</p>

</div>
</div>
<a id="a6550462400942be61b171c8840b36aa1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6550462400942be61b171c8840b36aa1">&#9670;&nbsp;</a></span>statevec_sqrtSwapGate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_sqrtSwapGate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00384">384</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;                                                          {</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;    </div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;    <a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a> u = (<a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a>) {.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>={{0}}, .imag={{0}}};</div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[0][0]=1;</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[3][3]=1;</div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[1][1] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[1][1] = .5;</div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[1][2] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[1][2] =-.5;</div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[2][1] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[2][1] =-.5;</div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[2][2] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[2][2] = .5;</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;    </div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;    <a class="code" href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a>(qureg, qb1, qb2, u);</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00128">ComplexMatrix4::imag</a>, <a class="el" href="QuEST_8h_source.html#l00127">ComplexMatrix4::real</a>, and <a class="el" href="QuEST__common_8c_source.html#l00517">statevec_twoQubitUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00613">sqrtSwapGate()</a>.</p>

</div>
</div>
<a id="a33cde9b6518d55a544eff20301a5d844"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a33cde9b6518d55a544eff20301a5d844">&#9670;&nbsp;</a></span>statevec_sqrtSwapGateConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_sqrtSwapGateConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00397">397</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;                                                              {</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;    </div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;    <a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a> u = (<a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a>) {.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>={{0}}, .imag={{0}}};</div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[0][0]=1;</div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[3][3]=1;</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[1][1] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[1][1] =-.5;</div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[1][2] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[1][2] = .5;</div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[2][1] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[2][1] = .5;</div>
<div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;    u.<a class="code" href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">real</a>[2][2] = .5; u.<a class="code" href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">imag</a>[2][2] =-.5;</div>
<div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;    </div>
<div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;    <a class="code" href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a>(qureg, qb1, qb2, u);</div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00128">ComplexMatrix4::imag</a>, <a class="el" href="QuEST_8h_source.html#l00127">ComplexMatrix4::real</a>, and <a class="el" href="QuEST__common_8c_source.html#l00517">statevec_twoQubitUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00613">sqrtSwapGate()</a>.</p>

</div>
</div>
<a id="ab7478fcaf6357ab202d72853b672e375"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab7478fcaf6357ab202d72853b672e375">&#9670;&nbsp;</a></span>statevec_swapQubitAmps()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_swapQubitAmps </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">1354</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01354"></a><span class="lineno"> 1354</span>&#160;                                                           {</div>
<div class="line"><a name="l01355"></a><span class="lineno"> 1355</span>&#160;    </div>
<div class="line"><a name="l01356"></a><span class="lineno"> 1356</span>&#160;    <span class="comment">// perform locally if possible </span></div>
<div class="line"><a name="l01357"></a><span class="lineno"> 1357</span>&#160;    <span class="keywordtype">int</span> qbBig = (qb1 &gt; qb2)? qb1 : qb2;</div>
<div class="line"><a name="l01358"></a><span class="lineno"> 1358</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, qbBig))</div>
<div class="line"><a name="l01359"></a><span class="lineno"> 1359</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__cpu_8c.html#ab5b51a28caa8792a3f0c637409a694b0">statevec_swapQubitAmpsLocal</a>(qureg, qb1, qb2);</div>
<div class="line"><a name="l01360"></a><span class="lineno"> 1360</span>&#160;        </div>
<div class="line"><a name="l01361"></a><span class="lineno"> 1361</span>&#160;    <span class="comment">// do nothing if this node contains no amplitudes to swap</span></div>
<div class="line"><a name="l01362"></a><span class="lineno"> 1362</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> oddParityGlobalInd = <a class="code" href="QuEST__cpu__distributed_8c.html#a4f243eb101c8e63f16cfd50300364cb7">getGlobalIndOfOddParityInChunk</a>(qureg, qb1, qb2);</div>
<div class="line"><a name="l01363"></a><span class="lineno"> 1363</span>&#160;    <span class="keywordflow">if</span> (oddParityGlobalInd == -1)</div>
<div class="line"><a name="l01364"></a><span class="lineno"> 1364</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l01365"></a><span class="lineno"> 1365</span>&#160; </div>
<div class="line"><a name="l01366"></a><span class="lineno"> 1366</span>&#160;    <span class="comment">// determine and swap amps with pair node</span></div>
<div class="line"><a name="l01367"></a><span class="lineno"> 1367</span>&#160;    <span class="keywordtype">int</span> pairRank = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(oddParityGlobalInd, qb1), qb2) / qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01368"></a><span class="lineno"> 1368</span>&#160;    <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01369"></a><span class="lineno"> 1369</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#abe74a5a9db8340e37b80fbc77338894d">statevec_swapQubitAmpsDistributed</a>(qureg, pairRank, qb1, qb2);</div>
<div class="line"><a name="l01370"></a><span class="lineno"> 1370</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01335">getGlobalIndOfOddParityInChunk()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03579">statevec_swapQubitAmpsDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03536">statevec_swapQubitAmpsLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">statevec_multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">statevec_multiControlledTwoQubitUnitary()</a>, and <a class="el" href="QuEST_8c_source.html#l00601">swapGate()</a>.</p>

</div>
</div>
<a id="a2d96b4601cc3a9e1221e11a366fe1699"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2d96b4601cc3a9e1221e11a366fe1699">&#9670;&nbsp;</a></span>statevec_tGate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_tGate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00272">272</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;                                                  {</div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;    <a class="code" href="structComplex.html">Complex</a> term; </div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;    term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = 1/sqrt(2);</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;    term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = 1/sqrt(2);</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a>(qureg, targetQubit, term);</div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02978">statevec_phaseShiftByTerm()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00477">tGate()</a>.</p>

</div>
</div>
<a id="a086fffa88b1aeec1405aa2dc41eab8a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a086fffa88b1aeec1405aa2dc41eab8a3">&#9670;&nbsp;</a></span>statevec_tGateConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_tGateConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00286">286</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;                                                      {</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;    <a class="code" href="structComplex.html">Complex</a> term; </div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;    term.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> =  1/sqrt(2);</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;    term.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = -1/sqrt(2);</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a>(qureg, targetQubit, term);</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02978">statevec_phaseShiftByTerm()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00477">tGate()</a>.</p>

</div>
</div>
<a id="a95abbe0cedf45b1ff2f070dba219fd7f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a95abbe0cedf45b1ff2f070dba219fd7f">&#9670;&nbsp;</a></span>statevec_twoQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_twoQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00517">517</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;                                                                                                 {</div>
<div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;    </div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> ctrlMask = 0;</div>
<div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a3eadcb581f2623e21e4967f791d0439c">statevec_multiControlledTwoQubitUnitary</a>(qureg, ctrlMask, targetQubit1, targetQubit2, u);</div>
<div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">statevec_multiControlledTwoQubitUnitary()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00853">applyMatrix4()</a>, <a class="el" href="QuEST__common_8c_source.html#l00384">statevec_sqrtSwapGate()</a>, <a class="el" href="QuEST__common_8c_source.html#l00397">statevec_sqrtSwapGateConj()</a>, and <a class="el" href="QuEST_8c_source.html#l00257">twoQubitUnitary()</a>.</p>

</div>
</div>
<a id="ac3735bd959600e57b2ee3a105666cddf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac3735bd959600e57b2ee3a105666cddf">&#9670;&nbsp;</a></span>statevec_unitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_unitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">881</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00882"></a><span class="lineno">  882</span>&#160;{</div>
<div class="line"><a name="l00883"></a><span class="lineno">  883</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00884"></a><span class="lineno">  884</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00885"></a><span class="lineno">  885</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00886"></a><span class="lineno">  886</span>&#160; </div>
<div class="line"><a name="l00887"></a><span class="lineno">  887</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00888"></a><span class="lineno">  888</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00889"></a><span class="lineno">  889</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00890"></a><span class="lineno">  890</span>&#160; </div>
<div class="line"><a name="l00891"></a><span class="lineno">  891</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00892"></a><span class="lineno">  892</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00893"></a><span class="lineno">  893</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#aafc398f8f479fcc066a2dea700235635">statevec_unitaryLocal</a>(qureg, targetQubit, u);</div>
<div class="line"><a name="l00894"></a><span class="lineno">  894</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00895"></a><span class="lineno">  895</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00896"></a><span class="lineno">  896</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00897"></a><span class="lineno">  897</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a>(rankIsUpper, &amp;rot1, &amp;rot2, u);</div>
<div class="line"><a name="l00898"></a><span class="lineno">  898</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00899"></a><span class="lineno">  899</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00900"></a><span class="lineno">  900</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00901"></a><span class="lineno">  901</span>&#160; </div>
<div class="line"><a name="l00902"></a><span class="lineno">  902</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. </span></div>
<div class="line"><a name="l00903"></a><span class="lineno">  903</span>&#160;        <span class="comment">// send values to compactUnitaryDistributed in the correct order</span></div>
<div class="line"><a name="l00904"></a><span class="lineno">  904</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00905"></a><span class="lineno">  905</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00906"></a><span class="lineno">  906</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00907"></a><span class="lineno">  907</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00908"></a><span class="lineno">  908</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00909"></a><span class="lineno">  909</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00910"></a><span class="lineno">  910</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00911"></a><span class="lineno">  911</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00912"></a><span class="lineno">  912</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00913"></a><span class="lineno">  913</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00914"></a><span class="lineno">  914</span>&#160;        }</div>
<div class="line"><a name="l00915"></a><span class="lineno">  915</span>&#160;    }</div>
<div class="line"><a name="l00916"></a><span class="lineno">  916</span>&#160; </div>
<div class="line"><a name="l00917"></a><span class="lineno">  917</span>&#160; </div>
<div class="line"><a name="l00918"></a><span class="lineno">  918</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02056">statevec_unitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01932">statevec_unitaryLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l00844">applyMatrix2()</a>, and <a class="el" href="QuEST_8c_source.html#l00349">unitary()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="astructVector_html"><div class="ttname"><a href="structVector.html">Vector</a></div><div class="ttdoc">Represents a 3-vector of real numbers.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00148">QuEST.h:148</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ae2b222fda52c10fb420cb3ac78ca31e4"><div class="ttname"><a href="QuEST__common_8c.html#ae2b222fda52c10fb420cb3ac78ca31e4">macro_setConjugateMatrix</a></div><div class="ttdeci">#define macro_setConjugateMatrix(dest, src, dim)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00093">QuEST_common.c:93</a></div></div>
<div class="ttc" id="astructComplexMatrix4_html_aeadc9893e1b16cdd585dac523e73926c"><div class="ttname"><a href="structComplexMatrix4.html#aeadc9893e1b16cdd585dac523e73926c">ComplexMatrix4::real</a></div><div class="ttdeci">qreal real[4][4]</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00127">QuEST.h:127</a></div></div>
<div class="ttc" id="agroup__debug_html_ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><div class="ttname"><a href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a></div><div class="ttdeci">void syncQuESTEnv(QuESTEnv env)</div><div class="ttdoc">Guarantees that all code up to the given point has been executed on all nodes (if running in distribu...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00162">QuEST_cpu_distributed.c:162</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ab987904f721746d1176aba7ac6b566fa"><div class="ttname"><a href="QuEST__common_8c.html#ab987904f721746d1176aba7ac6b566fa">densmatr_mixKrausMap</a></div><div class="ttdeci">void densmatr_mixKrausMap(Qureg qureg, int target, ComplexMatrix2 *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00600">QuEST_common.c:600</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ace1482ef82b83e7f926634a67b322fc4"><div class="ttname"><a href="QuEST__cpu_8c.html#ace1482ef82b83e7f926634a67b322fc4">statevec_controlledNotLocal</a></div><div class="ttdeci">void statevec_controlledNotLocal(Qureg qureg, int controlQubit, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02584">QuEST_cpu.c:2584</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_adb4b0373425b282abed27742d0ce0872"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a></div><div class="ttdeci">static void getRotAngle(int chunkIsUpper, Complex *rot1, Complex *rot2, Complex alpha, Complex beta)</div><div class="ttdoc">Get rotation values for a given chunk.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00258">QuEST_cpu_distributed.c:258</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a45b0916c3e121837f214b64f7424e479"><div class="ttname"><a href="QuEST__cpu_8c.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a></div><div class="ttdeci">void statevec_pauliYLocal(Qureg qureg, int targetQubit, int conjFac)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02682">QuEST_cpu.c:2682</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a939897137596bb73ad7a028d0beaaa10"><div class="ttname"><a href="QuEST__cpu_8c.html#a939897137596bb73ad7a028d0beaaa10">densmatr_calcHilbertSchmidtDistanceSquaredLocal</a></div><div class="ttdeci">qreal densmatr_calcHilbertSchmidtDistanceSquaredLocal(Qureg a, Qureg b)</div><div class="ttdoc">computes Tr((a-b) conjTrans(a-b)) = sum of abs values of (a-b)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00923">QuEST_cpu.c:923</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_aa648bb336cf8598467cb62db00b9cee8"><div class="ttname"><a href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">QuESTEnv::rank</a></div><div class="ttdeci">int rank</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00244">QuEST.h:244</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a2a6999e47bed978eb66f589c8abc7766"><div class="ttname"><a href="QuEST__common_8c.html#a2a6999e47bed978eb66f589c8abc7766">populateKrausSuperOperator4</a></div><div class="ttdeci">void populateKrausSuperOperator4(ComplexMatrixN *superOp, ComplexMatrix4 *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00567">QuEST_common.c:567</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a6dcb85ef8e1257813af0dc306082caf8"><div class="ttname"><a href="QuEST__common_8c.html#a6dcb85ef8e1257813af0dc306082caf8">populateKrausSuperOperatorN</a></div><div class="ttdeci">void populateKrausSuperOperatorN(ComplexMatrixN *superOp, ComplexMatrixN *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00571">QuEST_common.c:571</a></div></div>
<div class="ttc" id="agroup__type_html_ga9df2f3d86be4a6e9aad481665e5e6753"><div class="ttname"><a href="group__type.html#ga9df2f3d86be4a6e9aad481665e5e6753">destroyComplexMatrixN</a></div><div class="ttdeci">void destroyComplexMatrixN(ComplexMatrixN m)</div><div class="ttdoc">Destroy a ComplexMatrixN instance created with createComplexMatrixN()</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01120">QuEST.c:1120</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_ada3bffa8e414f883e415dd74e46cd879"><div class="ttname"><a href="structDiagonalOp.html#ada3bffa8e414f883e415dd74e46cd879">DiagonalOp::numChunks</a></div><div class="ttdeci">int numChunks</div><div class="ttdoc">The number of nodes between which the elements of this operator are split.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00185">QuEST.h:185</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_aef380928d1b0003411d6159ca6594cd5"><div class="ttname"><a href="QuEST__common_8c.html#aef380928d1b0003411d6159ca6594cd5">statevec_calcExpecPauliProd</a></div><div class="ttdeci">qreal statevec_calcExpecPauliProd(Qureg qureg, int *targetQubits, enum pauliOpType *pauliCodes, int numTargets, Qureg workspace)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00465">QuEST_common.c:465</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_af0ea25f00987af4c53f17c9cca62ab41"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a></div><div class="ttdeci">static int isChunkToSkipInFindPZero(int chunkId, long long int chunkSize, int measureQubit)</div><div class="ttdoc">Find chunks to skip when calculating probability of qubit being zero.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01251">QuEST_cpu_distributed.c:1251</a></div></div>
<div class="ttc" id="astructQureg_html_aba97773694870ef35e378c036f486bb7"><div class="ttname"><a href="structQureg.html#aba97773694870ef35e378c036f486bb7">Qureg::pairStateVec</a></div><div class="ttdeci">ComplexArray pairStateVec</div><div class="ttdoc">Temporary storage for a chunk of the state vector received from another process in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00224">QuEST.h:224</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a></div><div class="ttdeci">@ PAULI_I</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a430d98e35f1eae7f0815ac539057cf67"><div class="ttname"><a href="QuEST__cpu_8c.html#a430d98e35f1eae7f0815ac539057cf67">statevec_findProbabilityOfZeroDistributed</a></div><div class="ttdeci">qreal statevec_findProbabilityOfZeroDistributed(Qureg qureg)</div><div class="ttdoc">Measure the probability of a specified qubit being in the zero state across all amplitudes held in th...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03262">QuEST_cpu.c:3262</a></div></div>
<div class="ttc" id="agroup__type_html_ga815103261fb22ea9690e1427571df00e"><div class="ttname"><a href="group__type.html#ga815103261fb22ea9690e1427571df00e">createComplexMatrixN</a></div><div class="ttdeci">ComplexMatrixN createComplexMatrixN(int numQubits)</div><div class="ttdoc">Create (dynamically) a square complex matrix which can be passed to the multi-qubit general unitary f...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01099">QuEST.c:1099</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a88670d0e7cebe33f61c1dd98daa338b3"><div class="ttname"><a href="QuEST__cpu_8c.html#a88670d0e7cebe33f61c1dd98daa338b3">densmatr_mixDepolarisingDistributed</a></div><div class="ttdeci">void densmatr_mixDepolarisingDistributed(Qureg qureg, int targetQubit, qreal depolLevel)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00224">QuEST_cpu.c:224</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_acabdfbd3184d3ab3bded61e24142b800"><div class="ttname"><a href="QuEST__cpu_8c.html#acabdfbd3184d3ab3bded61e24142b800">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3(Qureg qureg, int targetQubit, int qubit2, qreal delta, qreal gamma)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00632">QuEST_cpu.c:632</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a95abbe0cedf45b1ff2f070dba219fd7f"><div class="ttname"><a href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a></div><div class="ttdeci">void statevec_twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00517">QuEST_common.c:517</a></div></div>
<div class="ttc" id="astructVector_html_ab33976d8fda2e44b770f71269d698a25"><div class="ttname"><a href="structVector.html#ab33976d8fda2e44b770f71269d698a25">Vector::z</a></div><div class="ttdeci">qreal z</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00150">QuEST.h:150</a></div></div>
<div class="ttc" id="astructQureg_html_aa3deb7163aab90a61e755a1f200f5413"><div class="ttname"><a href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">Qureg::numChunks</a></div><div class="ttdeci">int numChunks</div><div class="ttdoc">Number of chunks the state vector is broken up into – the number of MPI processes used.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00219">QuEST.h:219</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab5b51a28caa8792a3f0c637409a694b0"><div class="ttname"><a href="QuEST__cpu_8c.html#ab5b51a28caa8792a3f0c637409a694b0">statevec_swapQubitAmpsLocal</a></div><div class="ttdeci">void statevec_swapQubitAmpsLocal(Qureg qureg, int qb1, int qb2)</div><div class="ttdoc">It is ensured that all amplitudes needing to be swapped are on this node.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03536">QuEST_cpu.c:3536</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_accae504dfcd6846159baa16a1e8263a0"><div class="ttname"><a href="QuEST__common_8c.html#accae504dfcd6846159baa16a1e8263a0">statevec_applyPauliProd</a></div><div class="ttdeci">void statevec_applyPauliProd(Qureg workspace, int *targetQubits, enum pauliOpType *pauliCodes, int numTargets)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00451">QuEST_common.c:451</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a37e522505286f17fe6ef74b9f607a5c6"><div class="ttname"><a href="QuEST__cpu_8c.html#a37e522505286f17fe6ef74b9f607a5c6">getBitMaskParity</a></div><div class="ttdeci">int getBitMaskParity(long long int mask)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03100">QuEST_cpu.c:3100</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab58fe4be895283c2c4eb86ec9af5682e"><div class="ttname"><a href="QuEST__cpu_8c.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a></div><div class="ttdeci">void statevec_multiControlledUnitaryDistributed(Qureg qureg, int targetQubit, long long int ctrlQubitsMask, long long int ctrlFlipMask, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Apply a unitary operation to a single qubit in the state vector of probability amplitudes,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02447">QuEST_cpu.c:2447</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a0acfe30083d0bc2a84da196378a36122"><div class="ttname"><a href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a></div><div class="ttdeci">void statevec_multiControlledMultiQubitUnitary(Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdoc">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01437">QuEST_cpu_distributed.c:1437</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a8d88b4ed94ab024e5e7b2f1f4f505b44"><div class="ttname"><a href="QuEST__internal_8h.html#a8d88b4ed94ab024e5e7b2f1f4f505b44">statevec_multiRotateZ</a></div><div class="ttdeci">void statevec_multiRotateZ(Qureg qureg, long long int mask, qreal angle)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03109">QuEST_cpu.c:3109</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a57368529b2a7e76fec423cbfe9980b22"><div class="ttname"><a href="QuEST__cpu_8c.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a></div><div class="ttdeci">void statevec_controlledUnitaryDistributed(Qureg qureg, int controlQubit, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02381">QuEST_cpu.c:2381</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a63cb88a5f4eb12fef087435b8db3f8eb"><div class="ttname"><a href="QuEST__internal_8h.html#a63cb88a5f4eb12fef087435b8db3f8eb">statevec_calcProbOfOutcome</a></div><div class="ttdeci">qreal statevec_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01260">QuEST_cpu_distributed.c:1260</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab02bce0ebbb8f624e8ced8b09b99cdef"><div class="ttname"><a href="QuEST__cpu_8c.html#ab02bce0ebbb8f624e8ced8b09b99cdef">statevec_collapseToKnownProbOutcomeLocal</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcomeLocal(Qureg qureg, int measureQubit, int outcome, qreal totalProbability)</div><div class="ttdoc">Update the state vector to be consistent with measuring measureQubit=0 if outcome=0 and measureQubit=...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03380">QuEST_cpu.c:3380</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a373394db1bf71b0be63585c0e9a52abb"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a></div><div class="ttdeci">void compressPairVectorForTwoQubitDepolarise(Qureg qureg, int targetQubit, int qubit2)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00610">QuEST_cpu_distributed.c:610</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_aa91713a22c95a383bba55e56c4a4e37a"><div class="ttname"><a href="structDiagonalOp.html#aa91713a22c95a383bba55e56c4a4e37a">DiagonalOp::chunkId</a></div><div class="ttdeci">int chunkId</div><div class="ttdoc">The position of the chunk of the operator held by this process in the full operator.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00187">QuEST.h:187</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a5ddfdb22e4704b680d67d08d9e80835b"><div class="ttname"><a href="QuEST__cpu_8c.html#a5ddfdb22e4704b680d67d08d9e80835b">statevec_compactUnitaryLocal</a></div><div class="ttdeci">void statevec_compactUnitaryLocal(Qureg qureg, int targetQubit, Complex alpha, Complex beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01688">QuEST_cpu.c:1688</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_af910c7cf2b85bdc2c399cfe8dbfb8b9c"><div class="ttname"><a href="QuEST__cpu_8c.html#af910c7cf2b85bdc2c399cfe8dbfb8b9c">densmatr_calcPurityLocal</a></div><div class="ttdeci">qreal densmatr_calcPurityLocal(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00861">QuEST_cpu.c:861</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a16ccb485bcffb328bbd5b2af6977cead"><div class="ttname"><a href="QuEST__cpu_8c.html#a16ccb485bcffb328bbd5b2af6977cead">statevec_calcExpecDiagonalOpLocal</a></div><div class="ttdeci">Complex statevec_calcExpecDiagonalOpLocal(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03738">QuEST_cpu.c:3738</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a041bb75200ee316de7b90667a4fe04f3"><div class="ttname"><a href="QuEST__common_8c.html#a041bb75200ee316de7b90667a4fe04f3">getUnitVector</a></div><div class="ttdeci">Vector getUnitVector(Vector vec)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00078">QuEST_common.c:78</a></div></div>
<div class="ttc" id="astructComplexMatrix4_html"><div class="ttname"><a href="structComplexMatrix4.html">ComplexMatrix4</a></div><div class="ttdoc">Represents a 4x4 matrix of complex numbers.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00125">QuEST.h:125</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0aedcccfa50c7aaa8b7fc4c14d7cdfb8"><div class="ttname"><a href="QuEST__cpu_8c.html#a0aedcccfa50c7aaa8b7fc4c14d7cdfb8">statevec_multiControlledMultiQubitUnitaryLocal</a></div><div class="ttdeci">void statevec_multiControlledMultiQubitUnitaryLocal(Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01846">QuEST_cpu.c:1846</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a758bad4237ff0bf3b4ff5be626a982ae"><div class="ttname"><a href="QuEST__cpu_8c.html#a758bad4237ff0bf3b4ff5be626a982ae">statevec_initBlankState</a></div><div class="ttdeci">void statevec_initBlankState(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01398">QuEST_cpu.c:1398</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a71b3ae4402c1c5039d3086ca0e47a522"><div class="ttname"><a href="QuEST__common_8c.html#a71b3ae4402c1c5039d3086ca0e47a522">getComplexPairFromRotation</a></div><div class="ttdeci">void getComplexPairFromRotation(qreal angle, Vector axis, Complex *alpha, Complex *beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00114">QuEST_common.c:114</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_af8236a00389137b5eff986a40577eaf3"><div class="ttname"><a href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a></div><div class="ttdeci">void statevec_multiControlledTwoQubitUnitaryLocal(Qureg qureg, long long int ctrlMask, int q1, int q2, ComplexMatrix4 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01747">QuEST_cpu.c:1747</a></div></div>
<div class="ttc" id="astructComplexMatrixN_html"><div class="ttname"><a href="structComplexMatrixN.html">ComplexMatrixN</a></div><div class="ttdoc">Represents a general 2^N by 2^N matrix of complex numbers.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00136">QuEST.h:136</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a464efbd1d7ca5a7b25c83ada001955c2"><div class="ttname"><a href="QuEST__cpu_8c.html#a464efbd1d7ca5a7b25c83ada001955c2">statevec_pauliXDistributed</a></div><div class="ttdeci">void statevec_pauliXDistributed(Qureg qureg, ComplexArray stateVecIn, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit by {{0,1},{1,0}.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02556">QuEST_cpu.c:2556</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ae66dc6569c6e4008c33d6739db422c08"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a></div><div class="ttdeci">static int getChunkOuterBlockPairId(int chunkIsUpper, int chunkId, long long int chunkSize, int targetQubit, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00314">QuEST_cpu_distributed.c:314</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a95af772d87c461fc8abfd6d47b752ac2"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a></div><div class="ttdeci">void copyVecIntoMatrixPairState(Qureg matr, Qureg vec)</div><div class="ttdoc">This copies/clones vec (a statevector) into every node's matr pairState.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00371">QuEST_cpu_distributed.c:371</a></div></div>
<div class="ttc" id="agroup__type_html_ga7740e349b4f8bae6451547680f0ce2d6"><div class="ttname"><a href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a></div><div class="ttdeci">#define qreal</div></div>
<div class="ttc" id="aQuEST__common_8c_html_a4da103b16292ffd99197d05c5fa83712"><div class="ttname"><a href="QuEST__common_8c.html#a4da103b16292ffd99197d05c5fa83712">macro_allocStackComplexMatrixN</a></div><div class="ttdeci">#define macro_allocStackComplexMatrixN(matrix, numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00629">QuEST_common.c:629</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a37dae401754961c9100b3c0907913c3e"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a></div><div class="ttdeci">void exchangePairStateVectorHalves(Qureg qureg, int pairRank)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00509">QuEST_cpu_distributed.c:509</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a></div><div class="ttdeci">@ PAULI_X</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__gpu_8cu_html_ae1b7788cf504ec3d79de3855f97929c7"><div class="ttname"><a href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a></div><div class="ttdeci">__forceinline__ __device__ long long int flipBit(const long long int number, const int bitInd)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__gpu_8cu_source.html#l00095">QuEST_gpu.cu:95</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ab7478fcaf6357ab202d72853b672e375"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a></div><div class="ttdeci">void statevec_swapQubitAmps(Qureg qureg, int qb1, int qb2)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01354">QuEST_cpu_distributed.c:1354</a></div></div>
<div class="ttc" id="astructQureg_html_a0a86e8a50ea8c998b4a0a6640c5a1218"><div class="ttname"><a href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">Qureg::numQubitsInStateVec</a></div><div class="ttdeci">int numQubitsInStateVec</div><div class="ttdoc">Number of qubits in the state-vector - this is double the number represented for mixed states.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00210">QuEST.h:210</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a7dba097f23f5d48dfdc9f3250444e2e4"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a></div><div class="ttdeci">static int getChunkPairId(int chunkIsUpper, int chunkId, long long int chunkSize, int targetQubit)</div><div class="ttdoc">get position of corresponding chunk, holding values required to update values in my chunk (with chunk...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00303">QuEST_cpu_distributed.c:303</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a6153547f245c05874161a105e9a2f02c"><div class="ttname"><a href="QuEST__internal_8h.html#a6153547f245c05874161a105e9a2f02c">densmatr_calcTotalProb</a></div><div class="ttdeci">qreal densmatr_calcTotalProb(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00053">QuEST_cpu_distributed.c:53</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a5658f2ecbbd4ea425db5f7dc7fc4ba92"><div class="ttname"><a href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a></div><div class="ttdeci">void densmatr_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)</div><div class="ttdoc">Renorms (/prob) every | * outcome * &gt;&lt; * outcome * | state, setting all others to zero.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00785">QuEST_cpu.c:785</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a7ea68e9132ed9db9c242353a33dba2f0"><div class="ttname"><a href="QuEST__cpu_8c.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a></div><div class="ttdeci">void statevec_collapseToOutcomeDistributedSetZero(Qureg qureg)</div><div class="ttdoc">Set all amplitudes in one chunk to 0.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03501">QuEST_cpu.c:3501</a></div></div>
<div class="ttc" id="astructQureg_html_ac2929e681d3d95591c18cf168dbbe4f0"><div class="ttname"><a href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">Qureg::chunkId</a></div><div class="ttdeci">int chunkId</div><div class="ttdoc">The position of the chunk of the state vector held by this process in the full state vector.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00217">QuEST.h:217</a></div></div>
<div class="ttc" id="astructVector_html_abc3cfc6c8e297b1153a373d84b981e6b"><div class="ttname"><a href="structVector.html#abc3cfc6c8e297b1153a373d84b981e6b">Vector::y</a></div><div class="ttdeci">qreal y</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00150">QuEST.h:150</a></div></div>
<div class="ttc" id="astructComplexMatrix2_html_a3a2b60a9e00ccef054a6de3b9307c1be"><div class="ttname"><a href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">ComplexMatrix2::imag</a></div><div class="ttdeci">qreal imag[2][2]</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00117">QuEST.h:117</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a85c3f52533efe831bbe40b9a48602388"><div class="ttname"><a href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">DiagonalOp::imag</a></div><div class="ttdeci">qreal * imag</div><div class="ttdoc">The imaginary values of the 2^numQubits complex elements.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00191">QuEST.h:191</a></div></div>
<div class="ttc" id="astructVector_html_a0d0459a5b731ac5fb3dff2c6134e6e88"><div class="ttname"><a href="structVector.html#a0d0459a5b731ac5fb3dff2c6134e6e88">Vector::x</a></div><div class="ttdeci">qreal x</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00150">QuEST.h:150</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a9d19fc690afb425d0df5feb09be567a3"><div class="ttname"><a href="QuEST__common_8c.html#a9d19fc690afb425d0df5feb09be567a3">generateMeasurementOutcome</a></div><div class="ttdeci">int generateMeasurementOutcome(qreal zeroProb, qreal *outcomeProb)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00155">QuEST_common.c:155</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a0eb14d48920ea469b0904ae63b47b589"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a></div><div class="ttdeci">void compressPairVectorForSingleQubitDepolarise(Qureg qureg, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00543">QuEST_cpu_distributed.c:543</a></div></div>
<div class="ttc" id="astructQureg_html_ab0ea0358482b62f43fdd781469607d97"><div class="ttname"><a href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">Qureg::numAmpsPerChunk</a></div><div class="ttdeci">long long int numAmpsPerChunk</div><div class="ttdoc">Number of probability amplitudes held in stateVec by this process In the non-MPI version,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00213">QuEST.h:213</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a3510f01d4d15dcc545564eb84c668cad"><div class="ttname"><a href="QuEST__cpu_8c.html#a3510f01d4d15dcc545564eb84c668cad">densmatr_mixTwoQubitDepolarisingLocal</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingLocal(Qureg qureg, int qubit1, int qubit2, qreal delta, qreal gamma)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00387">QuEST_cpu.c:387</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a5c9b2f129bdffaaba9857f6eddecbb17"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a></div><div class="ttdeci">static void getRotAngleFromUnitaryMatrix(int chunkIsUpper, Complex *rot1, Complex *rot2, ComplexMatrix2 u)</div><div class="ttdoc">Get rotation values for a given chunk given a unitary matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00283">QuEST_cpu_distributed.c:283</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a06fb16aa4af7c54d36052a14d3ad58a7"><div class="ttname"><a href="QuEST__cpu_8c.html#a06fb16aa4af7c54d36052a14d3ad58a7">statevec_controlledPauliYLocal</a></div><div class="ttdeci">void statevec_controlledPauliYLocal(Qureg qureg, int controlQubit, int targetQubit, int conjFac)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02776">QuEST_cpu.c:2776</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_af3db21114efc431ae7a7ae06fc2d7b5b"><div class="ttname"><a href="QuEST__common_8c.html#af3db21114efc431ae7a7ae06fc2d7b5b">densmatr_applyKrausSuperoperator</a></div><div class="ttdeci">void densmatr_applyKrausSuperoperator(Qureg qureg, int target, ComplexMatrix4 superOp)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00576">QuEST_common.c:576</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a717a0448066831cb5b392bcf2e1d0529"><div class="ttname"><a href="QuEST__cpu_8c.html#a717a0448066831cb5b392bcf2e1d0529">densmatr_oneQubitDegradeOffDiagonal</a></div><div class="ttdeci">void densmatr_oneQubitDegradeOffDiagonal(Qureg qureg, int targetQubit, qreal retain)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00048">QuEST_cpu.c:48</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a758bad4237ff0bf3b4ff5be626a982ae"><div class="ttname"><a href="QuEST__internal_8h.html#a758bad4237ff0bf3b4ff5be626a982ae">statevec_initBlankState</a></div><div class="ttdeci">void statevec_initBlankState(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01398">QuEST_cpu.c:1398</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_abd00ba1321c9bd43c3a9119f5b3ed1be"><div class="ttname"><a href="QuEST__common_8c.html#abd00ba1321c9bd43c3a9119f5b3ed1be">populateKrausSuperOperator2</a></div><div class="ttdeci">void populateKrausSuperOperator2(ComplexMatrix4 *superOp, ComplexMatrix2 *ops, int numOps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00563">QuEST_common.c:563</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0abdff5f6065f9d57065345e6d90fc94"><div class="ttname"><a href="QuEST__cpu_8c.html#a0abdff5f6065f9d57065345e6d90fc94">alternateNormZeroingSomeAmpBlocks</a></div><div class="ttdeci">void alternateNormZeroingSomeAmpBlocks(Qureg qureg, qreal norm, int normFirst, long long int startAmpInd, long long int numAmps, long long int blockSize)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00754">QuEST_cpu.c:754</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_aa4b77089145184d990848cd66993aa8b"><div class="ttname"><a href="QuEST__internal_8h.html#aa4b77089145184d990848cd66993aa8b">statevec_cloneQureg</a></div><div class="ttdeci">void statevec_cloneQureg(Qureg targetQureg, Qureg copyQureg)</div><div class="ttdoc">works for both statevectors and density matrices</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01506">QuEST_cpu.c:1506</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_adf5fbea75826cde7d86fd7c31bcf3dec"><div class="ttname"><a href="QuEST__common_8c.html#adf5fbea75826cde7d86fd7c31bcf3dec">statevec_rotateAroundAxis</a></div><div class="ttdeci">void statevec_rotateAroundAxis(Qureg qureg, int rotQubit, qreal angle, Vector axis)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00311">QuEST_common.c:311</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_af22aacd7c9905accae28484785c193b4"><div class="ttname"><a href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">QuESTEnv::numRanks</a></div><div class="ttdeci">int numRanks</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00245">QuEST.h:245</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a623e577b7230f3c8dc202be6185b4289"><div class="ttname"><a href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a></div><div class="ttdeci">void densmatr_mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal dephase)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00084">QuEST_cpu.c:84</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0a7a35628b1c1eb47336deb9afda5b68"><div class="ttname"><a href="QuEST__cpu_8c.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a></div><div class="ttdeci">void statevec_compactUnitaryDistributed(Qureg qureg, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02001">QuEST_cpu.c:2001</a></div></div>
<div class="ttc" id="astructComplexMatrix4_html_a1f6bb840b5a9e6252980cab7a14f1a35"><div class="ttname"><a href="structComplexMatrix4.html#a1f6bb840b5a9e6252980cab7a14f1a35">ComplexMatrix4::imag</a></div><div class="ttdeci">qreal imag[4][4]</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00128">QuEST.h:128</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a3eadcb581f2623e21e4967f791d0439c"><div class="ttname"><a href="QuEST__internal_8h.html#a3eadcb581f2623e21e4967f791d0439c">statevec_multiControlledTwoQubitUnitary</a></div><div class="ttdeci">void statevec_multiControlledTwoQubitUnitary(Qureg qureg, long long int ctrlMask, int targetQubit1, int targetQubit2, ComplexMatrix4 u)</div><div class="ttdoc">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01381">QuEST_cpu_distributed.c:1381</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ae01c3eb75fd32de1a7e1dbc7a33a21e3"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a></div><div class="ttdeci">void exchangeStateVectors(Qureg qureg, int pairRank)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00479">QuEST_cpu_distributed.c:479</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a5131eeb67aafb4c19ac98270c3266742"><div class="ttname"><a href="structDiagonalOp.html#a5131eeb67aafb4c19ac98270c3266742">DiagonalOp::numQubits</a></div><div class="ttdeci">int numQubits</div><div class="ttdoc">The number of qubits this operator can act on (informing its size)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00181">QuEST.h:181</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab19f28e68330da68ea3caa2bdef32da9"><div class="ttname"><a href="QuEST__cpu_8c.html#ab19f28e68330da68ea3caa2bdef32da9">statevec_multiControlledUnitaryLocal</a></div><div class="ttdeci">void statevec_multiControlledUnitaryLocal(Qureg qureg, int targetQubit, long long int ctrlQubitsMask, long long int ctrlFlipMask, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02173">QuEST_cpu.c:2173</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_acc45bb8300922ea5933e294921e25ea2"><div class="ttname"><a href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a></div><div class="ttdeci">long long int getQubitBitMask(int *qubits, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00044">QuEST_common.c:44</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a031a99b7e97779f3dc782feffe86e779"><div class="ttname"><a href="QuEST__cpu_8c.html#a031a99b7e97779f3dc782feffe86e779">normaliseSomeAmps</a></div><div class="ttdeci">void normaliseSomeAmps(Qureg qureg, qreal norm, long long int startInd, long long int numAmps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00744">QuEST_cpu.c:744</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_aec63559e8b9ab0e17efe18d64d2ceca6"><div class="ttname"><a href="QuEST__internal_8h.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a></div><div class="ttdeci">void statevec_compactUnitary(Qureg qureg, int targetQubit, Complex alpha, Complex beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00844">QuEST_cpu_distributed.c:844</a></div></div>
<div class="ttc" id="astructDiagonalOp_html"><div class="ttname"><a href="structDiagonalOp.html">DiagonalOp</a></div><div class="ttdoc">Represents a diagonal complex operator on the full Hilbert state of a Qureg.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00178">QuEST.h:178</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a></div><div class="ttdeci">@ PAULI_Y</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0f562af6cb665a8a7a3f80e9449734d5"><div class="ttname"><a href="QuEST__cpu_8c.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a></div><div class="ttdeci">void statevec_pauliYDistributed(Qureg qureg, ComplexArray stateVecIn, ComplexArray stateVecOut, int updateUpper, int conjFac)</div><div class="ttdoc">Rotate a single qubit by +-{{0,-i},{i,0}.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02739">QuEST_cpu.c:2739</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a8d9c19a3424f0ad89bfbfd920d65301d"><div class="ttname"><a href="QuEST__cpu_8c.html#a8d9c19a3424f0ad89bfbfd920d65301d">densmatr_mixDampingDistributed</a></div><div class="ttdeci">void densmatr_mixDampingDistributed(Qureg qureg, int targetQubit, qreal damping)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00300">QuEST_cpu.c:300</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_aeb4453a2e609e5359d2995bccf6663ca"><div class="ttname"><a href="QuEST__cpu_8c.html#aeb4453a2e609e5359d2995bccf6663ca">densmatr_calcExpecDiagonalOpLocal</a></div><div class="ttdeci">Complex densmatr_calcExpecDiagonalOpLocal(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03781">QuEST_cpu.c:3781</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_aa987d1e0ba97da2ca540194356dd62de"><div class="ttname"><a href="QuEST__cpu_8c.html#aa987d1e0ba97da2ca540194356dd62de">statevec_pauliXLocal</a></div><div class="ttdeci">void statevec_pauliXLocal(Qureg qureg, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02498">QuEST_cpu.c:2498</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a336c3286d2434fc892ebe20e9fa22a24"><div class="ttname"><a href="QuEST__common_8c.html#a336c3286d2434fc892ebe20e9fa22a24">statevec_controlledRotateAroundAxis</a></div><div class="ttdeci">void statevec_controlledRotateAroundAxis(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00327">QuEST_common.c:327</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a1b36518c8fbbc3a5084bb4ad1fb05ea5"><div class="ttname"><a href="QuEST__cpu_8c.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a></div><div class="ttdeci">void densmatr_initPureStateLocal(Qureg targetQureg, Qureg copyQureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01184">QuEST_cpu.c:1184</a></div></div>
<div class="ttc" id="aQuEST__gpu_8cu_html_aec1852e1a8e70d3690919ce8ab551ba0"><div class="ttname"><a href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a></div><div class="ttdeci">__forceinline__ __device__ int extractBit(const int locationOfBitFromRight, const long long int theEncodedNumber)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__gpu_8cu_source.html#l00082">QuEST_gpu.cu:82</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a7ebd3198a198f4cd20840f64fd8b84d0"><div class="ttname"><a href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a></div><div class="ttdeci">Complex statevec_calcInnerProduct(Qureg bra, Qureg ket)</div><div class="ttdoc">Terrible code which unnecessarily individually computes and sums the real and imaginary components of...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00035">QuEST_cpu_distributed.c:35</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ad64a23933361fafc1b6b1787759c2663"><div class="ttname"><a href="QuEST__internal_8h.html#ad64a23933361fafc1b6b1787759c2663">statevec_setWeightedQureg</a></div><div class="ttdeci">void statevec_setWeightedQureg(Complex fac1, Qureg qureg1, Complex fac2, Qureg qureg2, Complex facOut, Qureg out)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03619">QuEST_cpu.c:3619</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a008becc4a18f868340836e0ab9fd6df6"><div class="ttname"><a href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01298">QuEST_cpu_distributed.c:1298</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab124a3a9956046bf9c0e1e3ae9171f42"><div class="ttname"><a href="QuEST__cpu_8c.html#ab124a3a9956046bf9c0e1e3ae9171f42">densmatr_mixDampingLocal</a></div><div class="ttdeci">void densmatr_mixDampingLocal(Qureg qureg, int targetQubit, qreal damping)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00174">QuEST_cpu.c:174</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_abd509244d57657e148e4084c5ab5d28f"><div class="ttname"><a href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a></div><div class="ttdeci">qreal statevec_getImagAmp(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00208">QuEST_cpu_distributed.c:208</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a08392b1b27d10e3b8a8648a5afeaa629"><div class="ttname"><a href="QuEST__cpu_8c.html#a08392b1b27d10e3b8a8648a5afeaa629">densmatr_calcInnerProductLocal</a></div><div class="ttdeci">qreal densmatr_calcInnerProductLocal(Qureg a, Qureg b)</div><div class="ttdoc">computes Tr(conjTrans(a) b) = sum of (a_ij^* b_ij)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00958">QuEST_cpu.c:958</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a28be36627b2dd9a0da63dd6f60121b06"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a></div><div class="ttdeci">static int getChunkIdFromIndex(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00194">QuEST_cpu_distributed.c:194</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0ce2c2fd54df25495e99dc5b95bed4b2"><div class="ttname"><a href="QuEST__cpu_8c.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a></div><div class="ttdeci">void statevec_unitaryDistributed(Qureg qureg, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Apply a unitary operation to a single qubit given a subset of the state vector with upper and lower b...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02056">QuEST_cpu.c:2056</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a071baf8b6951d2a7d6529394b6f39364"><div class="ttname"><a href="QuEST__cpu_8c.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a></div><div class="ttdeci">void statevec_controlledCompactUnitaryDistributed(Qureg qureg, int controlQubit, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02319">QuEST_cpu.c:2319</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a076fe6125da4d6037b8bc4d912df4015"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a></div><div class="ttdeci">static int densityMatrixBlockFitsInChunk(long long int chunkSize, int numQubits, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00363">QuEST_cpu_distributed.c:363</a></div></div>
<div class="ttc" id="astructQureg_html_a441e4cacef6bd17adb9813c7442d42fe"><div class="ttname"><a href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">Qureg::stateVec</a></div><div class="ttdeci">ComplexArray stateVec</div><div class="ttdoc">Computational state amplitudes - a subset thereof in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00222">QuEST.h:222</a></div></div>
<div class="ttc" id="astructComplexMatrix2_html_a3ea98d545b67a190ee6abe936c72076f"><div class="ttname"><a href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">ComplexMatrix2::real</a></div><div class="ttdeci">qreal real[2][2]</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00116">QuEST.h:116</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab750fb47da2fca9849c678c869e40e69"><div class="ttname"><a href="QuEST__cpu_8c.html#ab750fb47da2fca9849c678c869e40e69">densmatr_mixDepolarisingLocal</a></div><div class="ttdeci">void densmatr_mixDepolarisingLocal(Qureg qureg, int targetQubit, qreal depolLevel)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00125">QuEST_cpu.c:125</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ad09bb76ad67581b03ab176832cca37cf"><div class="ttname"><a href="QuEST__cpu_8c.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcomeDistributedRenorm(Qureg qureg, int measureQubit, qreal totalProbability)</div><div class="ttdoc">Renormalise parts of the state vector where measureQubit=0 or 1, based on the total probability of th...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03462">QuEST_cpu.c:3462</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a4d043bb0cee54a5f94faf3ffc34a6790"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a></div><div class="ttdeci">static int halfMatrixBlockFitsInChunk(long long int chunkSize, int targetQubit)</div><div class="ttdoc">return whether the current qubit rotation will use blocks that fit within a single chunk.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00356">QuEST_cpu_distributed.c:356</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a2c6eab631ef48b4978db026c98180eee"><div class="ttname"><a href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">DiagonalOp::numElemsPerChunk</a></div><div class="ttdeci">long long int numElemsPerChunk</div><div class="ttdoc">The number of the 2^numQubits amplitudes stored on each distributed node.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00183">QuEST.h:183</a></div></div>
<div class="ttc" id="astructQureg_html_acf78445e9435d09f44f0cc832c6aee79"><div class="ttname"><a href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">Qureg::isDensityMatrix</a></div><div class="ttdeci">int isDensityMatrix</div><div class="ttdoc">Whether this instance is a density-state representation.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00206">QuEST.h:206</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a86dbcc3db99294add9964741e19fbdab"><div class="ttname"><a href="QuEST__cpu_8c.html#a86dbcc3db99294add9964741e19fbdab">statevec_hadamardLocal</a></div><div class="ttdeci">void statevec_hadamardLocal(Qureg qureg, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02872">QuEST_cpu.c:2872</a></div></div>
<div class="ttc" id="astructComplexMatrixN_html_a606f7afbc3f65a596bdca21cb43be6a8"><div class="ttname"><a href="structComplexMatrixN.html#a606f7afbc3f65a596bdca21cb43be6a8">ComplexMatrixN::numQubits</a></div><div class="ttdeci">int numQubits</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00138">QuEST.h:138</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_afa58cf7cb98a25ab33621120c5c330d0"><div class="ttname"><a href="QuEST__cpu_8c.html#afa58cf7cb98a25ab33621120c5c330d0">densmatr_applyDiagonalOpLocal</a></div><div class="ttdeci">void densmatr_applyDiagonalOpLocal(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03696">QuEST_cpu.c:3696</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a903beb4f5d8753a964ce2dc5f9096a24"><div class="ttname"><a href="QuEST__cpu_8c.html#a903beb4f5d8753a964ce2dc5f9096a24">statevec_controlledUnitaryLocal</a></div><div class="ttdeci">void statevec_controlledUnitaryLocal(Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02241">QuEST_cpu.c:2241</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a4f243eb101c8e63f16cfd50300364cb7"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a4f243eb101c8e63f16cfd50300364cb7">getGlobalIndOfOddParityInChunk</a></div><div class="ttdeci">long long int getGlobalIndOfOddParityInChunk(Qureg qureg, int qb1, int qb2)</div><div class="ttdoc">returns -1 if this node contains no amplitudes where qb1 and qb2 have opposite parity,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01335">QuEST_cpu_distributed.c:1335</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a3d39314af5d88822d4aefb5e9cc4e2f6"><div class="ttname"><a href="QuEST__common_8c.html#a3d39314af5d88822d4aefb5e9cc4e2f6">densmatr_applyTwoQubitKrausSuperoperator</a></div><div class="ttdeci">void densmatr_applyTwoQubitKrausSuperoperator(Qureg qureg, int target1, int target2, ComplexMatrixN superOp)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00582">QuEST_common.c:582</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a535cc3c9962d511078691e4d64b4e272"><div class="ttname"><a href="QuEST__internal_8h.html#a535cc3c9962d511078691e4d64b4e272">statevec_phaseShiftByTerm</a></div><div class="ttdeci">void statevec_phaseShiftByTerm(Qureg qureg, int targetQubit, Complex term)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02978">QuEST_cpu.c:2978</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ae90f82418e0aa67218d733dbbc681998"><div class="ttname"><a href="QuEST__cpu_8c.html#ae90f82418e0aa67218d733dbbc681998">densmatr_mixTwoQubitDepolarisingLocalPart1</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingLocalPart1(Qureg qureg, int qubit1, int qubit2, qreal delta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00488">QuEST_cpu.c:488</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_aefba328e047e6ef4fd1ae4b56901aaa7"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#aefba328e047e6ef4fd1ae4b56901aaa7">copyDiagOpIntoMatrixPairState</a></div><div class="ttdeci">void copyDiagOpIntoMatrixPairState(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01482">QuEST_cpu_distributed.c:1482</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a393da4c4bc582a757ca8406d8501aca0"><div class="ttname"><a href="QuEST__cpu_8c.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a></div><div class="ttdeci">void statevec_controlledNotDistributed(Qureg qureg, int controlQubit, ComplexArray stateVecIn, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit by {{0,1},{1,0}.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02646">QuEST_cpu.c:2646</a></div></div>
<div class="ttc" id="astructQureg_html_ad08dff5316b8937f4b2a1417591543dc"><div class="ttname"><a href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">Qureg::numQubitsRepresented</a></div><div class="ttdeci">int numQubitsRepresented</div><div class="ttdoc">The number of qubits represented in either the state-vector or density matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00208">QuEST.h:208</a></div></div>
<div class="ttc" id="astructQureg_html_adef4935cac95763c29164cf99b144ed4"><div class="ttname"><a href="structQureg.html#adef4935cac95763c29164cf99b144ed4">Qureg::numAmpsTotal</a></div><div class="ttdeci">long long int numAmpsTotal</div><div class="ttdoc">Total number of amplitudes, which are possibly distributed among machines.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00215">QuEST.h:215</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a1d66088bed235d524cd452b107694d5c"><div class="ttname"><a href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">DiagonalOp::real</a></div><div class="ttdeci">qreal * real</div><div class="ttdoc">The real values of the 2^numQubits complex elements.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00189">QuEST.h:189</a></div></div>
<div class="ttc" id="astructComplex_html_ab5b2e2eca02131fc74b289a83636cbe3"><div class="ttname"><a href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">Complex::real</a></div><div class="ttdeci">qreal real</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00105">QuEST.h:105</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_abe74a5a9db8340e37b80fbc77338894d"><div class="ttname"><a href="QuEST__cpu_8c.html#abe74a5a9db8340e37b80fbc77338894d">statevec_swapQubitAmpsDistributed</a></div><div class="ttdeci">void statevec_swapQubitAmpsDistributed(Qureg qureg, int pairRank, int qb1, int qb2)</div><div class="ttdoc">qureg.pairStateVec contains the entire set of amplitudes of the paired node which includes the set of...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03579">QuEST_cpu.c:3579</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a514ca44595676abf4bc2e10fc48ef970"><div class="ttname"><a href="QuEST__common_8c.html#a514ca44595676abf4bc2e10fc48ef970">densmatr_applyMultiQubitKrausSuperoperator</a></div><div class="ttdeci">void densmatr_applyMultiQubitKrausSuperoperator(Qureg qureg, int *targets, int numTargets, ComplexMatrixN superOp)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00590">QuEST_common.c:590</a></div></div>
<div class="ttc" id="astructComplex_html_a84f5439aad0ef495efdd3b4c1c02d27e"><div class="ttname"><a href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">Complex::imag</a></div><div class="ttdeci">qreal imag</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00106">QuEST.h:106</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ab1ec7f241b68b079c8e316d190af49ce"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ab1ec7f241b68b079c8e316d190af49ce">getChunkOuterBlockPairIdForPart3</a></div><div class="ttdeci">static int getChunkOuterBlockPairIdForPart3(int chunkIsUpperSmallerQubit, int chunkIsUpperBiggerQubit, int chunkId, long long int chunkSize, int smallerQubit, int biggerQubit, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00325">QuEST_cpu_distributed.c:325</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a2f76ec8f08e19bb8e1254aafb10e160e"><div class="ttname"><a href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingDistributed(Qureg qureg, int targetQubit, int qubit2, qreal delta, qreal gamma)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00541">QuEST_cpu.c:541</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_aafc398f8f479fcc066a2dea700235635"><div class="ttname"><a href="QuEST__cpu_8c.html#aafc398f8f479fcc066a2dea700235635">statevec_unitaryLocal</a></div><div class="ttdeci">void statevec_unitaryLocal(Qureg qureg, int targetQubit, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01932">QuEST_cpu.c:1932</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a8bea931504c90d9bd97e74645667804e"><div class="ttname"><a href="QuEST__cpu_8c.html#a8bea931504c90d9bd97e74645667804e">densmatr_findProbabilityOfZeroLocal</a></div><div class="ttdeci">qreal densmatr_findProbabilityOfZeroLocal(Qureg qureg, int measureQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03151">QuEST_cpu.c:3151</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_aa3c2d644a2be7f0d3aa9f757527d306f"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a></div><div class="ttdeci">static int chunkIsUpperInOuterBlock(int chunkId, long long int chunkSize, int targetQubit, int numQubits)</div><div class="ttdoc">fix – do with masking instead</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00236">QuEST_cpu_distributed.c:236</a></div></div>
<div class="ttc" id="astructComplex_html"><div class="ttname"><a href="structComplex.html">Complex</a></div><div class="ttdoc">Represents one complex number.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00103">QuEST.h:103</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_abea6570b95fdfa102511ccd1fcb30685"><div class="ttname"><a href="QuEST__cpu_8c.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a></div><div class="ttdeci">void statevec_hadamardDistributed(Qureg qureg, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut, int updateUpper)</div><div class="ttdoc">Rotate a single qubit by {{1,1},{1,-1}}/sqrt2.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02932">QuEST_cpu.c:2932</a></div></div>
<div class="ttc" id="aQuEST__cpu__internal_8h_html_ae94d012c3da6c84599e99f6afea81f5f"><div class="ttname"><a href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a></div><div class="ttdeci">static int maskContainsBit(const long long int mask, const int bitInd)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__internal_8h_source.html#l00034">QuEST_cpu_internal.h:34</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ae37b3eff5d3affbc1edfe216cabc1c53"><div class="ttname"><a href="QuEST__internal_8h.html#ae37b3eff5d3affbc1edfe216cabc1c53">densmatr_calcProbOfOutcome</a></div><div class="ttdeci">qreal densmatr_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01276">QuEST_cpu_distributed.c:1276</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a4f419c557e4505da481879407a920541"><div class="ttname"><a href="QuEST__common_8c.html#a4f419c557e4505da481879407a920541">applySymmetrizedTrotterCircuit</a></div><div class="ttdeci">void applySymmetrizedTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00753">QuEST_common.c:753</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a790add229738945812ae2048c03d58ec"><div class="ttname"><a href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a></div><div class="ttdeci">void statevec_controlledPauliYDistributed(Qureg qureg, int controlQubit, ComplexArray stateVecIn, ComplexArray stateVecOut, int conjFac)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02830">QuEST_cpu.c:2830</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a215e2d6f88dbecc0b408b3573b5e144f"><div class="ttname"><a href="QuEST__cpu_8c.html#a215e2d6f88dbecc0b408b3573b5e144f">statevec_controlledCompactUnitaryLocal</a></div><div class="ttdeci">void statevec_controlledCompactUnitaryLocal(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02101">QuEST_cpu.c:2101</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a0552889d6f57d9e0ed8b209bf426482d"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a></div><div class="ttdeci">static int chunkIsUpper(int chunkId, long long int chunkSize, int targetQubit)</div><div class="ttdoc">Returns whether a given chunk in position chunkId is in the upper or lower half of a block.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00227">QuEST_cpu_distributed.c:227</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a1275d604674224d87a173fb5bac78835"><div class="ttname"><a href="QuEST__internal_8h.html#a1275d604674224d87a173fb5bac78835">statevec_controlledCompactUnitary</a></div><div class="ttdeci">void statevec_controlledCompactUnitary(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00920">QuEST_cpu_distributed.c:920</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_abc9a9ef4344c7faaaf28ac25c76649b9"><div class="ttname"><a href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a></div><div class="ttdeci">qreal statevec_getRealAmp(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00198">QuEST_cpu_distributed.c:198</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a6fbb3b693f25dde1e9e3dc87dc1984f7"><div class="ttname"><a href="QuEST__cpu_8c.html#a6fbb3b693f25dde1e9e3dc87dc1984f7">statevec_calcInnerProductLocal</a></div><div class="ttdeci">Complex statevec_calcInnerProductLocal(Qureg bra, Qureg ket)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01071">QuEST_cpu.c:1071</a></div></div>
<div class="ttc" id="astructComplexMatrix2_html"><div class="ttname"><a href="structComplexMatrix2.html">ComplexMatrix2</a></div><div class="ttdoc">Represents a 2x2 matrix of complex numbers.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00114">QuEST.h:114</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ac5168399122f7f53977dcc9ceda4f458"><div class="ttname"><a href="QuEST__cpu_8c.html#ac5168399122f7f53977dcc9ceda4f458">zeroSomeAmps</a></div><div class="ttdeci">void zeroSomeAmps(Qureg qureg, long long int startInd, long long int numAmps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00734">QuEST_cpu.c:734</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a7772f97cb4d92a9825bf3b7c82c3230c"><div class="ttname"><a href="QuEST__cpu_8c.html#a7772f97cb4d92a9825bf3b7c82c3230c">densmatr_calcFidelityLocal</a></div><div class="ttdeci">qreal densmatr_calcFidelityLocal(Qureg qureg, Qureg pureState)</div><div class="ttdoc">computes a few dens-columns-worth of (vec^*T) dens * vec</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00990">QuEST_cpu.c:990</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a8535bc15c2ff249ddddb3fde6eff1490"><div class="ttname"><a href="QuEST__cpu_8c.html#a8535bc15c2ff249ddddb3fde6eff1490">statevec_findProbabilityOfZeroLocal</a></div><div class="ttdeci">qreal statevec_findProbabilityOfZeroLocal(Qureg qureg, int measureQubit)</div><div class="ttdoc">Measure the total probability of a specified qubit being in the zero state across all amplitudes in t...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03206">QuEST_cpu.c:3206</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
        <script type="text/javascript" src="boot.js"></script>
</html>
